Changed Walking Tree direction change behavior.
authorRicardo Cruz <rick2@aeiou.pt>
Sat, 14 Aug 2004 11:50:58 +0000 (11:50 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Sat, 14 Aug 2004 11:50:58 +0000 (11:50 +0000)
SVN-Revision: 1776

src/badguy.cpp

index 1009314..5b762bb 100644 (file)
@@ -818,29 +818,11 @@ BadGuy::action_wingling(double elapsed_time)
 void
 BadGuy::action_walkingtree(double elapsed_time)
 {
-  Player& tux = *Sector::current()->player;
-  Direction v_dir = physic.get_velocity_x() < 0 ? LEFT : RIGHT;
-
   if (dying == DYING_NOT)
     check_horizontal_bump();
 
   fall();
 
-  if (mode == BGM_BIG && tux.dying == DYING_NOT)
-  {
-    if ((tux.base.x + tux.base.width/2 > base.x + base.width/2) && v_dir == LEFT)
-    {
-      dir = RIGHT;
-      physic.set_velocity_x(-physic.get_velocity_x());
-    }
-    else if ((tux.base.x + tux.base.width/2 < base.x + base.width/2) && v_dir == RIGHT)
-    {
-      dir = LEFT;
-      physic.set_velocity_x(-physic.get_velocity_x());
-    }
-  }
-  
-
   physic.apply(elapsed_time, base.x, base.y, Sector::current()->gravity);
   if (dying != DYING_FALLING)
     collision_swept_object_map(&old_base,&base);
@@ -1131,6 +1113,12 @@ BadGuy::squish(Player* player)
     {
       set_sprite(img_walkingtree_left_small, img_walkingtree_left_small);
       physic.set_velocity_x(physic.get_velocity_x() * 2.0f);
+
+      /* Move to the player's direction */
+      if(dir != Sector::current()->player->dir)
+        physic.set_velocity_x(-physic.get_velocity_x());
+      dir = Sector::current()->player->dir;
+
       // XXX magic number: 66 is BGM_BIG height
 
       player->bounce(this);