Use svnversion program rather than finding the svn package to get revision number
[supertux.git] / src / badguy / toad.cpp
index f416d8a..0f0582b 100644 (file)
@@ -1,4 +1,4 @@
-//  $Id: toad.cpp 4192 2006-08-16 23:25:39Z sommer $
+//  $Id$
 //
 //  Toad - A jumping toad
 //  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
@@ -30,13 +30,13 @@ namespace {
 }
 
 Toad::Toad(const lisp::Lisp& reader)
-       : BadGuy(reader, "images/creatures/toad/toad.sprite")
+        : BadGuy(reader, "images/creatures/toad/toad.sprite")
 {
   sound_manager->preload(HOP_SOUND);
 }
 
 Toad::Toad(const Vector& pos, Direction d)
-       : BadGuy(pos, d, "images/creatures/toad/toad.sprite")
+        : BadGuy(pos, d, "images/creatures/toad/toad.sprite")
 {
   sound_manager->preload(HOP_SOUND);
 }
@@ -51,7 +51,7 @@ Toad::write(lisp::Writer& writer)
 }
 
 void
-Toad::activate()
+Toad::initialize()
 {
   // initial state is JUMPING, because we might start airborne
   state = JUMPING;
@@ -62,16 +62,16 @@ void
 Toad::set_state(ToadState newState)
 {
   if (newState == IDLE) {
-    physic.vx = 0;
-    physic.vy = 0;
+    physic.set_velocity_x(0);
+    physic.set_velocity_y(0);
     sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
 
     recover_timer.start(RECOVER_TIME);
   } else
   if (newState == JUMPING) {
     sprite->set_action(dir == LEFT ? "jumping-left" : "jumping-right");
-    physic.vx = (dir == LEFT ? -HORIZONTAL_SPEED : HORIZONTAL_SPEED);
-    physic.vy = VERTICAL_SPEED;
+    physic.set_velocity_x(dir == LEFT ? -HORIZONTAL_SPEED : HORIZONTAL_SPEED);
+    physic.set_velocity_y(VERTICAL_SPEED);
     sound_manager->play( HOP_SOUND, get_pos());
   } else
   if (newState == FALLING) {
@@ -108,7 +108,7 @@ Toad::collision_solid(const CollisionHit& hit)
   }
 
   // check if we hit left or right while moving in either direction
-  if(((physic.vx < 0) && hit.left) || ((physic.vx > 0) && hit.right)) {
+  if(((physic.get_velocity_x() < 0) && hit.left) || ((physic.get_velocity_x() > 0) && hit.right)) {
     /*
     dir = dir == LEFT ? RIGHT : LEFT;
     if (state == JUMPING) {
@@ -117,7 +117,7 @@ Toad::collision_solid(const CollisionHit& hit)
       sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
     }
     */
-    physic.vx = -0.25*physic.vx;
+    physic.set_velocity_x(-0.25*physic.get_velocity_x());
   }
 
   // check if we hit the floor while falling
@@ -128,7 +128,7 @@ Toad::collision_solid(const CollisionHit& hit)
 
   // check if we hit the roof while climbing
   if ((state == JUMPING) && hit.top) {
-    physic.vy = 0;
+    physic.set_velocity_y(0);
   }
 
 }
@@ -148,7 +148,7 @@ Toad::active_update(float elapsed_time)
   BadGuy::active_update(elapsed_time);
 
   // change sprite when we are falling
-  if ((state == JUMPING) && (physic.vy > 0)) {
+  if ((state == JUMPING) && (physic.get_velocity_y() > 0)) {
     set_state(FALLING);
     return;
   }