From: Florian Forster Date: Sun, 28 Feb 2010 09:23:36 +0000 (+0000) Subject: Walking badguy: Implemented {get,set}_walk_speed. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bd331b46434b5be2862aa20874ac1feca82e45d4;p=supertux.git Walking badguy: Implemented {get,set}_walk_speed. SVN-Revision: 6442 --- 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();