Removed vertical flipping drawing hacks.
[supertux.git] / src / badguy.cpp
index b7879b5..09adc6d 100644 (file)
@@ -834,11 +834,29 @@ BadGuy::action_wingling(double elapsed_time)
 void
 BadGuy::action_walkingtree(double elapsed_time)
 {
+  Player& tux = *World::current()->get_tux();
+  Direction v_dir = physic.get_velocity_x() < 0 ? LEFT : RIGHT;
+
   if (dying == DYING_NOT)
     check_horizontal_bump();
 
   fall();
 
+  if (mode == BGM_BIG)
+  {
+    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);
   if (dying != DYING_FALLING)
     collision_swept_object_map(&old_base,&base);
@@ -978,7 +996,10 @@ BadGuy::draw(Camera& viewport, int)
     }
 
   Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right;
-  sprite->draw(viewport.world2screen(Vector(base.x, base.y)));
+  if(dying == DYING_FALLING)
+    sprite->draw(viewport.world2screen(Vector(base.x, base.y)), SD_VERTICAL_FLIP);
+  else
+    sprite->draw(viewport.world2screen(Vector(base.x, base.y)));
 
   if (debug_mode)
     fillrect(base.x - scroll_x, base.y - scroll_y, base.width, base.height, 75,0,75, 150);
@@ -1140,12 +1161,11 @@ BadGuy::squish(Player* player)
     if (mode == BGM_BIG)
     {
       set_sprite(img_walkingtree_left_small, img_walkingtree_left_small);
-      physic.set_velocity_x(physic.get_velocity_x() * 1.1);
+      physic.set_velocity_x(physic.get_velocity_x() * 2.0f);
       // XXX magic number: 66 is BGM_BIG height
-      base.y += 66 - base.height;
 
-      player->base.y = base.y - player->base.height - 2;
       make_player_jump(player);
+      base.y += 66 - base.height;
              
       World::current()->add_score(Vector(base.x, base.y),
                                 25 * player_status.score_multiplier);
@@ -1156,8 +1176,6 @@ BadGuy::squish(Player* player)
     else
       squish_me(player);
   }
-    
-  
 }
 
 void