@@ -85,34 +85,36 @@ Brick::hit(Player& player)
8585HitResponse
8686Brick::collision (MovingObject& other, const CollisionHit& hit)
8787{
88- auto player = dynamic_cast <Player*> (&other);
89- if (player && player->m_does_buttjump ) try_break (player);
90-
91- auto badguy = dynamic_cast <BadGuy*> (&other);
92- if (badguy) {
93- // Hit contains no information for collisions with blocks.
94- // Badguy's bottom has to be below the top of the brick
95- // SHIFT_DELTA is required to slide over one tile gaps.
96- if ( badguy->can_break () && ( badguy->get_bbox ().get_bottom () > m_col.m_bbox .get_top () + SHIFT_DELTA ) ) {
97- try_break (nullptr );
88+ if (hit.has_direction ()) {
89+ auto player = dynamic_cast <Player*> (&other);
90+ if (player && player->m_does_buttjump ) try_break (player);
91+
92+ auto badguy = dynamic_cast <BadGuy*> (&other);
93+ if (badguy) {
94+ // Hit contains no information for collisions with blocks.
95+ // Badguy's bottom has to be below the top of the brick
96+ // SHIFT_DELTA is required to slide over one tile gaps.
97+ if ( badguy->can_break () && ( badguy->get_bbox ().get_bottom () > m_col.m_bbox .get_top () + SHIFT_DELTA ) ) {
98+ try_break (nullptr );
99+ }
98100 }
99- }
100- auto portable = dynamic_cast <Portable*> (&other);
101- if (portable && !badguy) {
102- if (other.get_bbox ().get_top () > m_col.m_bbox .get_bottom () - SHIFT_DELTA) {
101+ auto portable = dynamic_cast <Portable*> (&other);
102+ if (portable && !badguy) {
103+ if (other.get_bbox ().get_top () > m_col.m_bbox .get_bottom () - SHIFT_DELTA) {
104+ try_break (nullptr );
105+ }
106+ }
107+
108+ auto explosion = dynamic_cast <Explosion*> (&other);
109+ if (explosion && explosion->hurts ()) {
103110 try_break (nullptr );
104111 }
105- }
106112
107- auto explosion = dynamic_cast <Explosion *> (&other);
108- if (explosion && explosion-> hurts ()) {
109- try_break (nullptr );
113+ auto crusher = dynamic_cast <Crusher *> (&other);
114+ if (crusher && crusher-> get_state () == Crusher::CRUSHING && m_coin_counter == 0 )
115+ try_break (nullptr );
110116 }
111117
112- auto crusher = dynamic_cast <Crusher*> (&other);
113- if (crusher && crusher->get_state () == Crusher::CRUSHING && m_coin_counter == 0 )
114- try_break (nullptr );
115-
116118 return Block::collision (other, hit);
117119}
118120
0 commit comments