Updated code to support new stuff from 0.1.2.
[supertux.git] / src / badguy.cpp
index 6ace8e3..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);
@@ -1314,9 +1302,9 @@ BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
               dir = RIGHT;
               physic.set_velocity_x(fabsf(physic.get_velocity_x()));
 
-              // in case badguys get "jammed"
-              if (physic.get_velocity_x() != 0)
-                base.x = pbad_c->base.x + pbad_c->base.width;
+              // Put bad guys a part (or they get jammed)
+              // only needed to do to one of them
+              base.x = pbad_c->base.x + pbad_c->base.width + 1;
             }
             else if (dir == RIGHT)
             {