Let Tux bounce off badguys when he's invincible. This let's us bounce off guys like...
authorRyan Flegel <rflegel@gmail.com>
Fri, 28 Apr 2006 03:26:19 +0000 (03:26 +0000)
committerRyan Flegel <rflegel@gmail.com>
Fri, 28 Apr 2006 03:26:19 +0000 (03:26 +0000)
Tux no longer kicks mriceblocks right before picking them up.

SVN-Revision: 3456

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

index 51a03f8..fb2fff9 100644 (file)
@@ -167,11 +167,6 @@ BadGuy::collision_solid(GameObject& , const CollisionHit& )
 HitResponse
 BadGuy::collision_player(Player& player, const CollisionHit& )
 {
-  if(player.is_invincible()) {
-    kill_fall();
-    return ABORT_MOVE;
-  }
-
   /*
   printf("PlayerHit: GT %3.1f PM: %3.1f %3.1f BM: %3.1f %3.1f Hit: %3.1f %3.1f\n",
           game_time,
@@ -187,6 +182,11 @@ BadGuy::collision_player(Player& player, const CollisionHit& )
       return ABORT_MOVE;
   }
 
+  if(player.is_invincible()) {
+    kill_fall();
+    return ABORT_MOVE;
+  }
+
   player.kill(false);
   return FORCE_MOVE;
 }
index 3361f41..1ec23a9 100644 (file)
 #include "mriceblock.hpp"
 #include "object/block.hpp"
 
-static const float WALKSPEED = 80;
-static const float KICKSPEED = 500;
-static const int MAXSQUISHES = 10;
+namespace {
+  const float WALKSPEED = 80;
+  const float KICKSPEED = 500;
+  const int MAXSQUISHES = 10;
+}
 
 MrIceBlock::MrIceBlock(const lisp::Lisp& reader)
   : ice_state(ICESTATE_NORMAL), squishcount(0)
@@ -146,13 +148,18 @@ MrIceBlock::collision_player(Player& player, const CollisionHit& hit)
 
   // handle kicks from left or right side
   if(ice_state == ICESTATE_FLAT && get_state() == STATE_ACTIVE) {
+    // Don't kick if the player is going to pick us up
+    if (player.get_controller()->hold(Controller::ACTION))
+        return FORCE_MOVE;
+
     // hit from left side
     if(hit.normal.x > 0.7) {
       dir = RIGHT;
       player.kick();
       set_state(ICESTATE_KICKED);
       return FORCE_MOVE;
-    } else if(hit.normal.x < -0.7) {
+    }
+    else if(hit.normal.x < -0.7) {
       dir = LEFT;
       player.kick();
       set_state(ICESTATE_KICKED);