Walking badguy: Implemented {get,set}_walk_speed.
[supertux.git] / src / badguy / walking_badguy.cpp
index 90ba94d..e92be3f 100644 (file)
@@ -14,6 +14,8 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include <math.h>
+
 #include "badguy/walking_badguy.hpp"
 
 #include "sprite/sprite.hpp"
@@ -75,6 +77,13 @@ WalkingBadguy::initialize()
 }
 
 void
+WalkingBadguy::set_walk_speed (float ws)
+{
+  walk_speed = fabs (ws);
+  physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed);
+}
+
+void
 WalkingBadguy::active_update(float elapsed_time)
 {
   BadGuy::active_update(elapsed_time);