try to fix badguys walking on water
[supertux.git] / src / badguy / badguy.cpp
index 65b2997..308e3e9 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;
@@ -116,8 +118,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)
@@ -181,7 +191,7 @@ BadGuy::collision_squished(Player& )
 void
 BadGuy::kill_squished(Player& player)
 {
-  sound_manager->play("sounds/squish.ogg", get_pos());
+  sound_manager->play("sounds/squish.wav", get_pos());
   physic.enable_gravity(true);
   physic.set_velocity_x(0);
   physic.set_velocity_y(0);
@@ -193,7 +203,7 @@ BadGuy::kill_squished(Player& player)
 void
 BadGuy::kill_fall()
 {
-  sound_manager->play("sounds/fall.ogg", get_pos());
+  sound_manager->play("sounds/fall.wav", get_pos());
   global_stats.add_points(BADGUYS_KILLED_STAT, 1);
   physic.set_velocity_y(0);
   physic.enable_gravity(true);