fix mriceblock grabbing
authorMatthias Braun <matze@braunis.de>
Tue, 16 May 2006 18:53:16 +0000 (18:53 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 16 May 2006 18:53:16 +0000 (18:53 +0000)
SVN-Revision: 3540

src/badguy/badguy.cpp
src/badguy/mriceblock.cpp
src/object/player.cpp
src/object/player.hpp

index 8718b19..57bf79b 100644 (file)
@@ -146,7 +146,7 @@ BadGuy::collision(GameObject& other, const CollisionHit& hit)
         return collision_solid(other, hit);
 
       BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
-      if(badguy && badguy->state == STATE_ACTIVE)
+      if(badguy && badguy->state == STATE_ACTIVE && badguy->get_group() == COLGROUP_MOVING)
         return collision_badguy(*badguy, hit);
 
       Player* player = dynamic_cast<Player*> (&other);
index 60dd66c..a7a7856 100644 (file)
@@ -141,15 +141,12 @@ MrIceBlock::collision_player(Player& player, const CollisionHit& hit)
   // handle kicks from left or right side
   if(ice_state == ICESTATE_FLAT && get_state() == STATE_ACTIVE) {
     // hit from left side
-    if(hit.normal.x > 0.7 &&
-            !player.get_controller()->hold(Controller::ACTION)) {
+    if(hit.normal.x > 0.7) {
       dir = RIGHT;
       player.kick();
       set_state(ICESTATE_KICKED);
       return FORCE_MOVE;
-    }
-    else if(hit.normal.x < -0.7 &&
-            !player.get_controller()->hold(Controller::ACTION)) {
+    } else if(hit.normal.x < -0.7) {
       dir = LEFT;
       player.kick();
       set_state(ICESTATE_KICKED);
index a7643b7..14c20e3 100644 (file)
@@ -102,7 +102,7 @@ TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer)
 }
 
 Player::Player(PlayerStatus* _player_status)
-  : player_status(_player_status), grabbed_object(0)
+  : player_status(_player_status), grabbed_object(NULL)
 {
   controller = main_controller;
   smalltux_gameover = sprite_manager->create("images/creatures/tux_small/smalltux-gameover.sprite");
@@ -150,7 +150,7 @@ Player::init()
   visible = true;
   
   on_ground_flag = false;
-  grabbed_object = 0;
+  grabbed_object = NULL;
 
   floor_normal = Vector(0,-1);
 
@@ -195,15 +195,16 @@ Player::update(float elapsed_time)
 
   movement = physic.get_movement(elapsed_time);
 
-  if(grabbed_object != 0 && !dying ) {
+  if(grabbed_object != NULL && !dying) {
     Vector pos = get_pos() + 
       Vector(dir == LEFT ? -16 : 16,
              bbox.get_height()*0.66666 - 32);
     grabbed_object->grab(*this, pos, dir);
   }
   
-  if(grabbed_object != 0 && dying){
+  if(grabbed_object != NULL && dying){
     grabbed_object->ungrab(*this, dir);
+    grabbed_object = NULL;
   }
 
   on_ground_flag = false;
@@ -480,7 +481,7 @@ Player::handle_input()
         log_debug << "Non MovingObjetc grabbed?!?" << std::endl;
       }
       grabbed_object->ungrab(*this, dir);
-      grabbed_object = 0;
+      grabbed_object = NULL;
     }
   }
  
@@ -764,9 +765,12 @@ Player::collision(GameObject& other, const CollisionHit& hit)
 
   if(other.get_flags() & FLAG_PORTABLE) {
     Portable* portable = dynamic_cast<Portable*> (&other);
-    if(portable && grabbed_object == 0 && controller->hold(Controller::ACTION)
+    assert(portable != NULL);
+    if(portable && grabbed_object == NULL
+        && controller->hold(Controller::ACTION)
         && fabsf(hit.normal.x) > .9) {
       grabbed_object = portable;
+      grabbed_object->grab(*this, get_pos(), dir);
       return CONTINUE;
     }
   }
index 3d7a239..2581c9f 100644 (file)
@@ -178,6 +178,11 @@ public:
 
   bool on_ground();
 
+  Portable* get_grabbed_object() const
+  {
+      return grabbed_object;
+  }
+
 private:
   void handle_input();
   bool deactivated;