}
void
-BonusBlock::hit(Player& )
+BonusBlock::hit(Player & player)
{
- try_open();
+ try_open(player);
}
HitResponse
Player* player = dynamic_cast<Player*> (&other);
if (player) {
- if (player->does_buttjump) try_open();
+ if (player->does_buttjump) try_open(*player);
}
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
// 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() > get_bbox().get_top() + SHIFT_DELTA ) ){
- try_open();
+ try_open(*player);
}
}
Portable* portable = dynamic_cast<Portable*> (&other);
if(portable) {
MovingObject* moving = dynamic_cast<MovingObject*> (&other);
if(moving->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA) {
- try_open();
+ try_open(*player);
}
}
return Block::collision(other, hit);
}
void
-BonusBlock::try_open()
+BonusBlock::try_open(Player & player)
{
if(sprite->get_action() == "empty") {
sound_manager->play("sounds/brick.wav");
Sector* sector = Sector::current();
assert(sector);
- assert(sector->player);
- Player& player = *(sector->player);
Direction direction = (player.get_bbox().get_middle().x > get_bbox().get_middle().x) ? LEFT : RIGHT;
switch(contents) {