src/PhysicsObject.cc
changeset 247 b87f68be579f
parent 241 e95b1602d836
child 252 25054ce94d07
--- a/src/PhysicsObject.cc	Sun Dec 07 17:45:42 2008 +0000
+++ b/src/PhysicsObject.cc	Sun Dec 07 18:21:44 2008 +0000
@@ -143,7 +143,7 @@
         // If, however, there's a force caused by a bomb, e.g., set it in air.
         // Still, we have to be able to separate forces caused by walking attempts
         // and bombs etc (+0.1 because float comparison can be dangerous)
-        if (total.y < 0 || abs(total.x) > PLAYER_MOVE_FORCE + 0.1)
+        if (total.y < 0.01 || abs(total.x) > PLAYER_MOVE_FORCE + 0.1)
             this->inAir = true;
     }
 
@@ -160,7 +160,10 @@
         if (total.x != 0) {
             walk(dt, total.x > 0);
             this->velocity = Vector(0,0);
-        }
+        }   
+        // Now the possible walking has been done so we can return from this function.
+        // In walk inAir could have been set true, but that will be handled in the next tick.
+        return;
     }
 
     if (!possibleLocation(position))
@@ -179,6 +182,8 @@
     const Vector diffVec = newPosition-position;
     const Vector unitVector = diffVec / diffVec.length();
     Vector reached = position;
+    
+    Engine::log(DEBUG, "physics.update_position") << "unitVector=" << unitVector;
 
     while ((position-reached).sqrLength() < diffVec.sqrLength()) {
         reached += unitVector;