* Fixed gradient background bug
[supertux.git] / src / badguy / badguy.cpp
index 8af3885..b1e2790 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "badguy.hpp"
 #include "object/camera.hpp"
+#include "object/tilemap.hpp"
+#include "tile.hpp"
 #include "statistics.hpp"
 
 static const float SQUISH_TIME = 2;
@@ -45,8 +47,8 @@ BadGuy::draw(DrawingContext& context)
   if(state == STATE_INIT || state == STATE_INACTIVE)
     return;
   if(state == STATE_FALLING) {
-    uint32_t old_effect = context.get_drawing_effect();
-    context.set_drawing_effect(old_effect | VERTICAL_FLIP);
+    DrawingEffect old_effect = context.get_drawing_effect();
+    context.set_drawing_effect((DrawingEffect) (old_effect | VERTICAL_FLIP));
     sprite->draw(context, get_pos(), LAYER_OBJECTS);
     context.set_drawing_effect(old_effect);
   } else {
@@ -98,6 +100,12 @@ BadGuy::deactivate()
 }
 
 void
+BadGuy::save(lisp::Writer& )
+{
+       std::cout << "Warning: tried to write out a generic badguy." << std::endl;
+}
+
+void
 BadGuy::active_update(float elapsed_time)
 {
   movement = physic.get_movement(elapsed_time);
@@ -116,8 +124,16 @@ BadGuy::collision(GameObject& other, const CollisionHit& hit)
     case STATE_INACTIVE:
       return ABORT_MOVE;
     case STATE_ACTIVE: {
-      if(other.get_flags() & FLAG_SOLID)
-        return collision_solid(other, hit);
+      TileMap* tilemap = dynamic_cast<TileMap*> (&other);
+      if(tilemap != 0) {
+        const TilemapCollisionHit* thit 
+          = static_cast<const TilemapCollisionHit*> (&hit);
+        if(thit->tileflags & Tile::SPIKE)
+          kill_fall();
+        if(thit->tileflags & Tile::SOLID)
+          return collision_solid(other, hit);
+        return FORCE_MOVE;
+      }
 
       BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
       if(badguy && badguy->state == STATE_ACTIVE)