本文整理汇总了C++中BadGuy::kill_me方法的典型用法代码示例。如果您正苦于以下问题:C++ BadGuy::kill_me方法的具体用法?C++ BadGuy::kill_me怎么用?C++ BadGuy::kill_me使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BadGuy
的用法示例。
在下文中一共展示了BadGuy::kill_me方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
Player::update(float elapsed_time)
{
if(dying && dying_timer.check()) {
dead = true;
return;
}
if(!dying && !deactivated)
handle_input();
// handle_input() calls apply_friction() when Tux is not walking, so we'll have to do this ourselves
if (deactivated) apply_friction();
// extend/shrink tux collision rectangle so that we fall through/walk over 1
// tile holes
if(fabsf(physic.get_velocity_x()) > MAX_WALK_XM) {
set_width(34);
} else {
set_width(31.8);
}
// on downward slopes, adjust vertical velocity so tux walks smoothly down
if (on_ground()) {
if(floor_normal.y != 0) {
if ((floor_normal.x * physic.get_velocity_x()) >= 0) {
physic.set_velocity_y(250);
}
}
}
// handle backflipping
if (backflipping) {
//prevent player from changing direction when backflipping
dir = (backflip_direction == 1) ? LEFT : RIGHT;
if (backflip_timer.started()) physic.set_velocity_x(100 * backflip_direction);
}
// set fall mode...
if(on_ground()) {
fall_mode = ON_GROUND;
last_ground_y = get_pos().y;
} else {
if(get_pos().y > last_ground_y)
fall_mode = FALLING;
else if(fall_mode == ON_GROUND)
fall_mode = JUMPING;
}
// check if we landed
if(on_ground()) {
jumping = false;
if (backflipping && (!backflip_timer.started())) {
backflipping = false;
backflip_direction = 0;
// if controls are currently deactivated, we take care of standing up ourselves
if (deactivated) do_standup();
}
}
#if 0
// Do butt jump
if (butt_jump && on_ground() && is_big()) {
// Add a smoke cloud
if (duck)
Sector::current()->add_smoke_cloud(Vector(get_pos().x - 32, get_pos().y));
else
Sector::current()->add_smoke_cloud(
Vector(get_pos().x - 32, get_pos().y + 32));
butt_jump = false;
// Break bricks beneath Tux
if(Sector::current()->trybreakbrick(
Vector(base.x + 1, base.y + base.height), false)
|| Sector::current()->trybreakbrick(
Vector(base.x + base.width - 1, base.y + base.height), false)) {
physic.set_velocity_y(-2);
butt_jump = true;
}
// Kill nearby badguys
std::vector<GameObject*> gameobjects = Sector::current()->gameobjects;
for (std::vector<GameObject*>::iterator i = gameobjects.begin();
i != gameobjects.end();
i++) {
BadGuy* badguy = dynamic_cast<BadGuy*> (*i);
if(badguy) {
// don't kill when badguys are already dying or in a certain mode
if(badguy->dying == DYING_NOT && badguy->mode != BadGuy::BOMB_TICKING &&
badguy->mode != BadGuy::BOMB_EXPLODE) {
if (fabsf(base.x - badguy->base.x) < 96 &&
fabsf(base.y - badguy->base.y) < 64)
badguy->kill_me(25);
}
}
}
}
#endif
//.........这里部分代码省略.........