HitResponse BonusBlock::collision(GameObject& other, const CollisionHit& hit_){ Player* player = dynamic_cast<Player*> (&other); if (player) { if (player->does_buttjump) try_drop(player); } BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy) { // hit contains no information for collisions with blocks. // Badguy's bottom has to be below the top of the block // SHIFT_DELTA is required to slide over one tile gaps. if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > bbox.get_top() + SHIFT_DELTA ) ){ try_open(player); } } Portable* portable = dynamic_cast<Portable*> (&other); if(portable) { MovingObject* moving = dynamic_cast<MovingObject*> (&other); if(moving->get_bbox().get_top() > bbox.get_bottom() - SHIFT_DELTA) { try_open(player); } } return Block::collision(other, hit_); }
HitResponse Brick::collision(GameObject& other, const CollisionHit& hit_){ Player* player = dynamic_cast<Player*> (&other); if (player) { if (player->does_buttjump) try_break(player); if (player->is_stone() && player->get_velocity().y >= 280) try_break(player); // stoneform breaks through bricks } BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy) { // hit contains no information for collisions with blocks. // Badguy's bottom has to be below the top of the brick // SHIFT_DELTA is required to slide over one tile gaps. if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > bbox.get_top() + SHIFT_DELTA ) ){ try_break(player); } } Portable* portable = dynamic_cast<Portable*> (&other); if(portable) { MovingObject* moving = dynamic_cast<MovingObject*> (&other); if(moving->get_bbox().get_top() > bbox.get_bottom() - SHIFT_DELTA) { try_break(player); } } Explosion* explosion = dynamic_cast<Explosion*> (&other); if(explosion && explosion->hurts()) { try_break(player); } IceCrusher* icecrusher = dynamic_cast<IceCrusher*> (&other); if(icecrusher && coin_counter == 0) try_break(player); return Block::collision(other, hit_); }
HitResponse Brick::collision(GameObject& other, const CollisionHit& hit){ BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy) { // hit contains no information for collisions with blocks. // Badguy's bottom has to be below the top of the brick // +7 is required to slide over one tile gaps. if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > get_bbox().get_top() + 7.0 ) ){ try_break(false); } } return Block::collision(other, hit); }
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(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); } Bullet* bullet = dynamic_cast<Bullet*> (&other); if(bullet) return collision_bullet(*bullet, hit); return FORCE_MOVE; }
HitResponse BonusBlock::collision(GameObject& other, const CollisionHit& hit){ BadGuy* badguy = dynamic_cast<BadGuy*> (&other); if(badguy) { // hit contains no information for collisions with blocks. // Badguy's bottom has to be below the top of the bonusblock // +7 is required to slide over one tile gaps. if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > get_bbox().get_top() + 7.0) ){ try_open(); } } Portable* portable = dynamic_cast<Portable*> (&other); if(portable) { MovingObject* moving = dynamic_cast<MovingObject*> (&other); if(moving->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) { try_open(); } } return Block::collision(other, hit); }
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) { // 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) { // 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; }