}
void
-Block::start_bounce(float center_of_hitter)
+Block::start_bounce(GameObject* hitter)
{
if(original_y == -1){
original_y = bbox.p1.y;
bounce_dir = -BOUNCY_BRICK_SPEED;
bounce_offset = 0;
- float offset = (get_bbox().get_middle().x - center_of_hitter)*2 / get_bbox().get_width();
- sprite->set_angle(BUMP_ROTATION_ANGLE*offset);
+ MovingObject* hitter_mo = dynamic_cast<MovingObject*>(hitter);
+ if (hitter_mo) {
+ float center_of_hitter = hitter_mo->get_bbox().get_middle().x;
+ float offset = (get_bbox().get_middle().x - center_of_hitter)*2 / get_bbox().get_width();
+ sprite->set_angle(BUMP_ROTATION_ANGLE*offset);
+ }
}
void
-Block::start_break(float center_of_hitter)
+Block::start_break(GameObject* hitter)
{
- start_bounce(center_of_hitter);
+ start_bounce(hitter);
breaking = true;
}
break;
}
- start_bounce(player.get_bbox().get_middle().x);
+ start_bounce(&player);
sprite->set_action("empty");
}
player_one.get_status()->add_coins(1);
if(coin_counter == 0)
sprite->set_action("empty");
- start_bounce(player->get_bbox().get_middle().x);
+ start_bounce(player);
} else if(breakable) {
if(player){
if(player->is_big()){
- start_break(player->get_bbox().get_middle().x);
+ start_break(player);
return;
} else {
- start_bounce(player->get_bbox().get_middle().x);
+ start_bounce(player);
return;
}
}
friend class FlipLevelTransformer;
virtual void hit(Player& player) = 0;
- void start_bounce(float center_of_hitter);
- void start_break(float center_of_hitter);
+ void start_bounce(GameObject* hitter);
+ void start_break(GameObject* hitter);
void break_me();
Sprite* sprite;