HitResponse BadGuy::collision(GameObject& other, const CollisionHit& hit) { if (!is_active()) return ABORT_MOVE; auto badguy = dynamic_cast<BadGuy*> (&other); if (badguy && badguy->is_active() && badguy->m_col.get_group() == COLGROUP_MOVING) { /* Badguys don't let badguys squish other badguys. It's bad. */ #if 0 // hit from above? if (badguy->get_bbox().get_bottom() < (bbox.get_top() + 16)) { if (collision_squished(*badguy)) { return ABORT_MOVE; } } #endif return collision_badguy(*badguy, hit); } auto player = dynamic_cast<Player*> (&other); if (player) { // hit from above? if (player->get_bbox().get_bottom() < (m_col.m_bbox.get_top() + 16)) { if (player->is_stone()) { kill_fall(); return FORCE_MOVE; } if (collision_squished(*player)) { return FORCE_MOVE; } } if (player->is_stone()) { collision_solid(hit); return FORCE_MOVE; } return collision_player(*player, hit); } auto bullet = dynamic_cast<Bullet*> (&other); if (bullet) return collision_bullet(*bullet, hit); return FORCE_MOVE; }
HitResponse BadGuy::collision(GameObject& other, const CollisionHit& hit) { if (!is_active()) return ABORT_MOVE; BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy && badguy->is_active() && badguy->get_group() == COLGROUP_MOVING) { /* Badguys don't let badguys squish other badguys. It's bad. */ #if 0 // hit from above? if (badguy->get_bbox().p2.y < (bbox.p1.y + 16)) { if(collision_squished(*badguy)) { return ABORT_MOVE; } } #endif return collision_badguy(*badguy, hit); } 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 FORCE_MOVE; } } return collision_player(*player, hit); } Bullet* bullet = dynamic_cast<Bullet*> (&other); if(bullet) return collision_bullet(*bullet, hit); return FORCE_MOVE; }