Walking badguy: Implemented {get,set}_walk_speed.
authorFlorian Forster <supertux@octo.it>
Sun, 28 Feb 2010 09:23:36 +0000 (09:23 +0000)
committerFlorian Forster <supertux@octo.it>
Sun, 28 Feb 2010 09:23:36 +0000 (09:23 +0000)
SVN-Revision: 6442

src/badguy/walking_badguy.cpp
src/badguy/walking_badguy.hpp

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);
index f316078..e7da438 100644 (file)
@@ -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();