Mr. Ice Block: Enforce 100ms delay between squish and kick (closes issue 238); kill...
authorChristoph Sommer <mail@christoph-sommer.de>
Sun, 6 Jan 2008 02:40:59 +0000 (02:40 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Sun, 6 Jan 2008 02:40:59 +0000 (02:40 +0000)
SVN-Revision: 5254

src/badguy/mriceblock.cpp
src/badguy/mriceblock.hpp

index cb801b3..f5d927e 100644 (file)
@@ -25,6 +25,7 @@
 namespace {
   const float KICKSPEED = 500;
   const int MAXSQUISHES = 10;
+  const float NOKICK_TIME = 0.1f;
 }
 
 MrIceBlock::MrIceBlock(const lisp::Lisp& reader)
@@ -105,10 +106,12 @@ MrIceBlock::collision_solid(const CollisionHit& hit)
       if(hit.right && dir == RIGHT) {
         dir = LEFT;
         sound_manager->play("sounds/iceblock_bump.wav", get_pos());
+        if(++squishcount >= MAXSQUISHES) { kill_fall(); break; }
         physic.set_velocity_x(-KICKSPEED);
       } else if(hit.left && dir == LEFT) {
         dir = RIGHT;
         sound_manager->play("sounds/iceblock_bump.wav", get_pos());
+        if(++squishcount >= MAXSQUISHES) { kill_fall(); break; }
         physic.set_velocity_x(KICKSPEED);
       }
       sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
@@ -190,6 +193,7 @@ MrIceBlock::collision_squished(GameObject& object)
       }
 
       set_state(ICESTATE_FLAT);
+      nokick_timer.start(NOKICK_TIME);
       break;
     case ICESTATE_FLAT:
       {
@@ -200,7 +204,7 @@ MrIceBlock::collision_squished(GameObject& object)
          dir = LEFT;
        }
       }
-      set_state(ICESTATE_KICKED);
+      if (nokick_timer.check()) set_state(ICESTATE_KICKED);
       break;
     case ICESTATE_GRABBED:
       assert(false);
index a00c5e7..9d6eb97 100644 (file)
@@ -60,6 +60,7 @@ private:
   void set_state(IceState state);
 
   IceState ice_state;
+  Timer nokick_timer;
   Timer flat_timer;
   int squishcount;
 };