From 1b8226124892f9b1d5bafbcf67f543780f12ade1 Mon Sep 17 00:00:00 2001 From: florianf Date: Sun, 28 Feb 2010 09:23:36 +0000 Subject: [PATCH] Walking badguy: Implemented {get,set}_walk_speed. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6442 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/badguy/walking_badguy.cpp | 9 +++++++++ src/badguy/walking_badguy.hpp | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/badguy/walking_badguy.cpp b/src/badguy/walking_badguy.cpp index 90ba94d3e..e92be3f09 100644 --- a/src/badguy/walking_badguy.cpp +++ b/src/badguy/walking_badguy.cpp @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #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); diff --git a/src/badguy/walking_badguy.hpp b/src/badguy/walking_badguy.hpp index f31607833..e7da43820 100644 --- a/src/badguy/walking_badguy.hpp +++ b/src/badguy/walking_badguy.hpp @@ -53,6 +53,12 @@ public: float get_velocity_y() const; void set_velocity_y(float vy); + float get_walk_speed (void) const + { + return (walk_speed); + } + void set_walk_speed (float); + protected: void turn_around(); -- 2.11.0