restore trunk
[supertux.git] / src / object / block.cpp
index de4f311..fd6e2fc 100644 (file)
@@ -32,6 +32,7 @@
 #include "video/drawing_context.hpp"
 #include "lisp/lisp.hpp"
 #include "gameobjs.hpp"
+#include "portable.hpp"
 #include "specialriser.hpp"
 #include "growup.hpp"
 #include "flower.hpp"
@@ -73,15 +74,25 @@ Block::collision(GameObject& other, const CollisionHit& )
     }
   }
 
-  if(bouncing) {
+  // 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()))) {
+
+    // 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;
@@ -223,6 +234,13 @@ BonusBlock::collision(GameObject& other, const CollisionHit& hit){
         try_open();
       }
     }
+    Portable* portable = dynamic_cast<Portable*> (&other);
+    if(portable) {
+      MovingObject* moving = dynamic_cast<MovingObject*> (&other);
+      if(moving->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) {
+        try_open();
+      }
+    }
     return Block::collision(other, hit);
 }
 
@@ -344,6 +362,13 @@ Brick::collision(GameObject& other, const CollisionHit& hit){
         try_break(false);
       }
     }
+    Portable* portable = dynamic_cast<Portable*> (&other);
+    if(portable) {
+      MovingObject* moving = dynamic_cast<MovingObject*> (&other);
+      if(moving->get_bbox().get_top() > get_bbox().get_bottom() - 7.0) {
+        try_break();
+      }
+    }
    return Block::collision(other, hit);
 }