Fixed problems with Rockets and Cannons sometimes reversing direction on
[supertux.git] / src / badguy / skullyhop.cpp
index 9282d29..a5ba2ca 100644 (file)
@@ -23,7 +23,7 @@
 #include "random_generator.hpp"
 
 namespace {
-  const float VERTICAL_SPEED = 450;   /**< y-speed when jumping */
+  const float VERTICAL_SPEED = -450;   /**< y-speed when jumping */
   const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */
   const float MIN_RECOVER_TIME = 0.1; /**< minimum time to stand still before starting a (new) jump */
   const float MAX_RECOVER_TIME = 1.0; /**< maximum time to stand still before starting a (new) jump */
@@ -32,14 +32,11 @@ namespace {
 SkullyHop::SkullyHop(const lisp::Lisp& reader)
        : BadGuy(reader, "images/creatures/skullyhop/skullyhop.sprite")
 {
-  has_initial_direction = false;
 }
 
 SkullyHop::SkullyHop(const Vector& pos, Direction d)
-       : BadGuy(pos, "images/creatures/skullyhop/skullyhop.sprite")
+       : BadGuy(pos, d, "images/creatures/skullyhop/skullyhop.sprite")
 {
-  has_initial_direction = true;
-  initial_direction = d;
 }
 
 void
@@ -54,8 +51,6 @@ SkullyHop::write(lisp::Writer& writer)
 void
 SkullyHop::activate()
 {
-  if (has_initial_direction) dir = initial_direction;
-
   // initial state is JUMPING, because we might start airborne
   state = JUMPING;
   sprite->set_action(dir == LEFT ? "jumping-left" : "jumping-right");
@@ -99,12 +94,12 @@ SkullyHop::collision_solid(GameObject& , const CollisionHit& hit)
   if(state != JUMPING) return CONTINUE;
 
   // check if we hit the floor while falling
-  if ((hit.normal.y < 0) && (physic.get_velocity_y() < 0)) {
+  if ((hit.normal.y < 0) && (physic.get_velocity_y() > 0)) {
     set_state(STANDING);
   }
 
   // check if we hit the roof while climbing
-  if ((hit.normal.y > 0) && (physic.get_velocity_y() > 0)) { 
+  if ((hit.normal.y > 0) && (physic.get_velocity_y() < 0)) { 
     physic.set_velocity_y(0);
   }