Made buttjump a bit easier to perform
[supertux.git] / src / object / block.cpp
index 395c33b..bb309f0 100644 (file)
@@ -74,16 +74,25 @@ Block::collision(GameObject& other, const CollisionHit& )
     }
   }
 
+  // only interact with other objects if...
+  //   1) we are bouncing
+  // and
+  //   2) the object is not portable (either never or not currently)
   Portable* portable = dynamic_cast<Portable*> (&other);
-  if(bouncing && (portable == 0 || portable->is_portable())) {
+  if(bouncing && (portable == 0 || (!portable->is_portable()))) {
+
+    // Badguys get killed
     BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
     if(badguy) {
       badguy->kill_fall();
     }
+
+    // Coins get collected
     Coin* coin = dynamic_cast<Coin*> (&other);
     if(coin) {
       coin->collect();
     }
+
   }
 
   return SOLID;
@@ -334,23 +343,29 @@ Brick::Brick(const Vector& pos, int data)
 }
 
 void
-Brick::hit(Player& )
+Brick::hit(Player& player)
 {
   if(sprite->get_action() == "empty")
     return;
 
-  try_break(true);
+  try_break(&player);
 }
 
 HitResponse
 Brick::collision(GameObject& other, const CollisionHit& hit){
+
+    Player* player = dynamic_cast<Player*> (&other);
+    if (player) {
+      if (player->does_buttjump) try_break();
+    }
+
     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);
+        try_break();
       }
     }
     Portable* portable = dynamic_cast<Portable*> (&other);
@@ -364,24 +379,24 @@ Brick::collision(GameObject& other, const CollisionHit& hit){
 }
 
 void
-Brick::try_break(bool playerhit)
+Brick::try_break(Player* player)
 {
   if(sprite->get_action() == "empty")
     return;
 
   sound_manager->play("sounds/brick.wav");
   Sector* sector = Sector::current();
-  Player& player = *(sector->player);
+  Player& player_one = *(sector->player);
   if(coin_counter > 0) {
     sector->add_object(new BouncyCoin(get_pos()));
     coin_counter--;
-    player.get_status()->add_coins(1);
+    player_one.get_status()->add_coins(1);
     if(coin_counter == 0)
       sprite->set_action("empty");
     start_bounce();
   } else if(breakable) {
-    if(playerhit){
-      if(player.is_big()){
+    if(player){
+      if(player->is_big()){
         start_break();
         return;
       } else {