BadGuy::update(float elapsed_time)
{
if(!Sector::current()->inside(bbox)) {
+ is_active_flag = false;
remove_me();
return;
}
switch(state) {
case STATE_ACTIVE:
+ is_active_flag = true;
active_update(elapsed_time);
break;
case STATE_INIT:
case STATE_INACTIVE:
+ is_active_flag = false;
inactive_update(elapsed_time);
try_activate();
break;
case STATE_SQUISHED:
+ is_active_flag = false;
if(state_timer.check()) {
remove_me();
break;
movement = physic.get_movement(elapsed_time);
break;
case STATE_FALLING:
+ is_active_flag = false;
movement = physic.get_movement(elapsed_time);
break;
}
HitResponse
BadGuy::collision(GameObject& other, const CollisionHit& hit)
{
- switch(state) {
- case STATE_INIT:
- case STATE_INACTIVE:
- return ABORT_MOVE;
- case STATE_ACTIVE: {
- BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
- if(badguy && badguy->state == STATE_ACTIVE && badguy->get_group() == COLGROUP_MOVING) {
-
- // hit from above?
- if (badguy->get_bbox().p2.y < (bbox.p1.y + 16)) {
- if(collision_squished(*badguy)) {
- return ABORT_MOVE;
- }
- }
-
- return collision_badguy(*badguy, hit);
- }
-
- Player* player = dynamic_cast<Player*> (&other);
- if(player) {
+ if (!is_active()) return ABORT_MOVE;
- // hit from above?
- if (player->get_bbox().p2.y < (bbox.p1.y + 16)) {
- if(collision_squished(*player)) {
- return ABORT_MOVE;
- }
- }
+ BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
+ if(badguy && badguy->is_active() && badguy->get_group() == COLGROUP_MOVING) {
- return collision_player(*player, hit);
+ // hit from above?
+ if (badguy->get_bbox().p2.y < (bbox.p1.y + 16)) {
+ if(collision_squished(*badguy)) {
+ return ABORT_MOVE;
}
+ }
- Bullet* bullet = dynamic_cast<Bullet*> (&other);
- if(bullet)
- return collision_bullet(*bullet, hit);
+ return collision_badguy(*badguy, hit);
+ }
- return FORCE_MOVE;
+ Player* player = dynamic_cast<Player*> (&other);
+ if(player) {
+
+ // hit from above?
+ if (player->get_bbox().p2.y < (bbox.p1.y + 16)) {
+ if(collision_squished(*player)) {
+ return ABORT_MOVE;
+ }
}
- case STATE_SQUISHED:
- return FORCE_MOVE;
- case STATE_FALLING:
- return FORCE_MOVE;
+
+ return collision_player(*player, hit);
}
- return ABORT_MOVE;
+ Bullet* bullet = dynamic_cast<Bullet*> (&other);
+ if(bullet)
+ return collision_bullet(*bullet, hit);
+
+ return FORCE_MOVE;
}
void
return on_ground_flag;
}
+bool
+BadGuy::is_active()
+{
+ return is_active_flag;
+}
+
Vector
BadGuy::get_floor_normal()
{