UnstableTile and WeakBlock are affected by Explosions.
authormathnerd314 <mathnerd314@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 17 Jan 2010 21:11:16 +0000 (21:11 +0000)
committermathnerd314 <mathnerd314@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Sun, 17 Jan 2010 21:11:16 +0000 (21:11 +0000)
git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6256 837edb03-e0f3-0310-88ca-d4d4e8b29345

src/object/explosion.cpp
src/object/unstable_tile.cpp
src/object/unstable_tile.hpp
src/object/weak_block.cpp

index 94a40d1..77d6b17 100644 (file)
 #include <math.h>
 
 Explosion::Explosion(const Vector& pos)
-  : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
+  : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_MOVING), state(STATE_WAITING)
 {
   sound_manager->preload("sounds/explosion.wav");
   set_pos(get_pos() - (get_bbox().get_middle() - get_pos()));
 }
 
 Explosion::Explosion(const Reader& reader)
-  : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
+  : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_MOVING), state(STATE_WAITING)
 {
   sound_manager->preload("sounds/explosion.wav");
 }
index 79d6b2a..5002d89 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "object/unstable_tile.hpp"
 
+#include "object/explosion.hpp"
 #include "object/player.hpp"
 #include "sprite/sprite.hpp"
 #include "supertux/constants.hpp"
@@ -37,14 +38,25 @@ UnstableTile::collision(GameObject& other, const CollisionHit& )
     Player* player = dynamic_cast<Player*> (&other);
     if(player != NULL &&
        player->get_bbox().get_bottom() < get_bbox().get_top() + SHIFT_DELTA) {
-      state = STATE_CRUMBLING;
-      sprite->set_action("crumbling", 1);
+      startCrumbling();
+    }
+
+    if (dynamic_cast<Explosion*> (&other)) {
+      startCrumbling();
     }
   }
   return FORCE_MOVE;
 }
 
 void
+UnstableTile::startCrumbling()
+{
+  if (state != STATE_NORMAL) return;
+  state = STATE_CRUMBLING;
+  sprite->set_action("crumbling", 1);
+}
+
+void
 UnstableTile::update(float elapsed_time)
 {
   switch (state) {
index 4c2cf17..f005bf1 100644 (file)
@@ -40,6 +40,8 @@ private:
     STATE_DISINTEGRATING /**< disintegrating, no longer solid */
   };
 
+  void startCrumbling();
+
 private:
   Physic physic;
   State state;
index eae7d0c..b9d10c5 100644 (file)
@@ -18,6 +18,7 @@
 #include "object/weak_block.hpp"
 
 #include "object/bullet.hpp"
+#include "object/explosion.hpp"
 #include "supertux/object_factory.hpp"
 #include "supertux/sector.hpp"
 
@@ -37,22 +38,21 @@ WeakBlock::collision(GameObject& other, const CollisionHit& )
     case STATE_NORMAL:
       if (dynamic_cast<Bullet*>(&other)) {
         startBurning();
-        return FORCE_MOVE;
       }
-      return FORCE_MOVE;
+      if (dynamic_cast<Explosion*> (&other)) {
+        startBurning();
+      }
       break;
 
     case STATE_BURNING:
-      return FORCE_MOVE;
-      break;
-
     case STATE_DISINTEGRATING:
-      return FORCE_MOVE;
       break;
 
+    default:
+      log_debug << "unhandled state" << std::endl;
+      break;
   }
 
-  log_debug << "unhandled state" << std::endl;
   return FORCE_MOVE;
 }