--- 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;
--- a/src/Vector.hh Sun Dec 07 17:45:42 2008 +0000
+++ b/src/Vector.hh Sun Dec 07 18:21:44 2008 +0000
@@ -50,8 +50,8 @@
T operator*(const _Vector &v) const {
return (this->x*v.x + this->y*v.y);
}
- _Vector operator/(const T &d) const {
- return _Vector(this->x/d, this->y/d);
+ _Vector operator/ (const T &d) const {
+ return _Vector(this->x / d, this->y / d);
}
void operator+=(const _Vector &v) {
*this = *this + v;