FlipLevelTransformer takes care of (Bonus)Blocks that move
authorChristoph Sommer <mail@christoph-sommer.de>
Wed, 5 Jul 2006 11:05:22 +0000 (11:05 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Wed, 5 Jul 2006 11:05:22 +0000 (11:05 +0000)
SVN-Revision: 3891

src/flip_level_transformer.cpp
src/flip_level_transformer.hpp
src/object/block.hpp

index 2d966de..e56ac2a 100644 (file)
@@ -56,6 +56,10 @@ FlipLevelTransformer::transform_sector(Sector* sector)
     if(platform) {
       transform_platform(height, *platform);
     }
+    Block* block = dynamic_cast<Block*> (object);
+    if(block) {
+      transform_block(height, *block);
+    }
     MovingObject* mobject = dynamic_cast<MovingObject*> (object);
     if(mobject) {
       transform_moving_object(height, mobject);
@@ -123,3 +127,9 @@ FlipLevelTransformer::transform_platform(float height, Platform& platform)
     pos.y = height - pos.y - platform.get_bbox().get_height();
   }
 }
+
+void 
+FlipLevelTransformer::transform_block(float height, Block& block)
+{
+  block.original_y = height - block.original_y - block.get_bbox().get_height();
+}
index fde90f8..bfb0c6f 100644 (file)
@@ -23,6 +23,7 @@
 #include "level_transformer.hpp"
 #include "object/platform.hpp"
 #include "object/path.hpp"
+#include "object/block.hpp"
 
 class TileMap;
 class BadGuy;
@@ -41,6 +42,7 @@ private:
   void transform_badguy(float height, BadGuy* badguy);
   void transform_spawnpoint(float height, SpawnPoint* spawnpoint);
   void transform_platform(float height, Platform& platform);
+  void transform_block(float height, Block& block);
 };
 
 #endif
index ac7bdd2..07b37cb 100644 (file)
@@ -37,6 +37,8 @@ public:
   virtual void draw(DrawingContext& context);
 
 protected:
+  friend class FlipLevelTransformer;
+
   virtual void hit(Player& player) = 0;
   void start_bounce();
 
@@ -45,6 +47,7 @@ protected:
   float bounce_dir;
   float bounce_offset;
   float original_y;
+
 };
 
 class BonusBlock : public Block