Completed airflower powerup abilities.
[supertux.git] / src / badguy / walking_badguy.cpp
index 8ab7d35..5e26d49 100644 (file)
 
 #include "sprite/sprite.hpp"
 
-WalkingBadguy::WalkingBadguy(const Vector& pos, 
-                             const std::string& sprite_name
-                             const std::string& walk_left_action
-                             const std::string& walk_right_action
-                             int layer) :
-  BadGuy(pos, sprite_name, layer), 
-  walk_left_action(walk_left_action), 
-  walk_right_action(walk_right_action), 
-  walk_speed(80), 
+WalkingBadguy::WalkingBadguy(const Vector& pos,
+                             const std::string& sprite_name_,
+                             const std::string& walk_left_action_,
+                             const std::string& walk_right_action_,
+                             int layer_) :
+  BadGuy(pos, sprite_name_, layer_),
+  walk_left_action(walk_left_action_),
+  walk_right_action(walk_right_action_),
+  walk_speed(80),
   max_drop_height(-1),
   turn_around_timer(),
   turn_around_counter()
 {
 }
 
-WalkingBadguy::WalkingBadguy(const Vector& pos, 
-                             Direction direction, 
-                             const std::string& sprite_name
-                             const std::string& walk_left_action
-                             const std::string& walk_right_action
-                             int layer) :
-  BadGuy(pos, direction, sprite_name, layer), 
-  walk_left_action(walk_left_action), 
-  walk_right_action(walk_right_action), 
-  walk_speed(80), 
+WalkingBadguy::WalkingBadguy(const Vector& pos,
+                             Direction direction,
+                             const std::string& sprite_name_,
+                             const std::string& walk_left_action_,
+                             const std::string& walk_right_action_,
+                             int layer_) :
+  BadGuy(pos, direction, sprite_name_, layer_),
+  walk_left_action(walk_left_action_),
+  walk_right_action(walk_right_action_),
+  walk_speed(80),
   max_drop_height(-1),
   turn_around_timer(),
   turn_around_counter()
 {
 }
 
-WalkingBadguy::WalkingBadguy(const Reader& reader, 
-                             const std::string& sprite_name
-                             const std::string& walk_left_action
-                             const std::string& walk_right_action
-                             int layer) :
-  BadGuy(reader, sprite_name, layer), 
-  walk_left_action(walk_left_action), 
-  walk_right_action(walk_right_action), 
-  walk_speed(80), 
+WalkingBadguy::WalkingBadguy(const Reader& reader,
+                             const std::string& sprite_name_,
+                             const std::string& walk_left_action_,
+                             const std::string& walk_right_action_,
+                             int layer_) :
+  BadGuy(reader, sprite_name_, layer_),
+  walk_left_action(walk_left_action_),
+  walk_right_action(walk_right_action_),
+  walk_speed(80),
   max_drop_height(-1),
   turn_around_timer(),
   turn_around_counter()
@@ -137,6 +137,15 @@ WalkingBadguy::active_update(float elapsed_time, float dest_x_velocity)
       turn_around();
     }
   }
+
+  if ((dir == LEFT) && (physic.get_velocity_x () > 0.0)) {
+    dir = RIGHT;
+    set_action (walk_right_action, /* loops = */ -1);
+  }
+  else if ((dir == RIGHT) && (physic.get_velocity_x () < 0.0)) {
+    dir = LEFT;
+    set_action (walk_left_action, /* loops = */ -1);
+  }
 }
 
 void