- 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);
+ }