diff -r 27ce69fd1e06 -r c080c8c70333 src/PhysicsObject.cc --- a/src/PhysicsObject.cc Mon Dec 08 15:02:05 2008 +0000 +++ b/src/PhysicsObject.cc Mon Dec 08 15:37:34 2008 +0000 @@ -9,6 +9,7 @@ float collision_elasticity, bool enabled) : world(world), position(position), + previousPosition(position), velocity(velocity), mass(mass), inAir(true), @@ -79,9 +80,8 @@ void PhysicsObject::walk (TimeMS dt, bool right) { float velocity = PLAYER_WALK_SPEED; float walkAmount = (velocity*dt)/1000; - Vector reached = this->position; - while (walkAmount > 0 && !this->inAir) { - this->position = walk_one_step((1 < walkAmount ? 1 : walkAmount), right); + while (walkAmount > 0){// && !this->inAir) { + setPosition (walk_one_step((1 < walkAmount ? 1 : walkAmount), right)); walkAmount--; } // TODO: Should the remaining walkAmount be handled somehow? @@ -240,11 +240,11 @@ // This means everything was ok, so no need to do anything } - this->position = newPosition; + setPosition (newPosition); } else { newPosition = reached; - this->position = newPosition; + setPosition (newPosition); // the following may delete this object, so it must be the last thing called onCollision(collisionPoint, NULL); @@ -327,7 +327,7 @@ } void PhysicsObject::updatePhysics (Vector position, Vector velocity, bool inAir, FacingDirection facing, float aim) { - this->position = position; + setPosition (position); this->velocity = velocity; this->inAir = inAir; this->facing = facing; @@ -338,6 +338,15 @@ return position; } +Vector PhysicsObject::getPreviousPosition (void) const { + return previousPosition; +} + +void PhysicsObject::setPosition (Vector pos) { + this->previousPosition = this->position; + this->position = pos; +} + PixelCoordinate PhysicsObject::getCoordinate (void) const { return world.getPixelCoordinate(position); }