--- a/src/proto2/Physics.cc Wed Dec 03 12:09:42 2008 +0000
+++ b/src/proto2/Physics.cc Wed Dec 03 12:21:38 2008 +0000
@@ -49,8 +49,11 @@
/**
* Player walks on floor.
*/
-Vector PhysicsObject::walk (bool right) {
- float deltaX = right ? 1 : -1; // which way we are walking
+Vector PhysicsObject::walk (TimeMS dt, bool right) {
+ // TODO: that dt should affect to something
+ float velocity = 100;
+ // which way we are walking
+ float deltaX = right ? (velocity*dt)/1000 : -(velocity*dt)/1000;
Vector reached = this->position;
// Is there upward ramp
@@ -78,10 +81,12 @@
// If the fall is big enough, set the worm in the air
if (i >= 2) {
+ Vector back = walk(dt, !right);
this->inAir = true;
- this->velocity.x = right ? 10 : -10;
+ this->velocity.x = right ? velocity : -velocity;
// Avoid stepping two pixels down when it starts to free fall
reached.y -= 2;
+ this->velocity = (reached-back)*1000/dt;
break;
}
}
@@ -169,7 +174,7 @@
// It walks only if there's some vertical force
if (total.x != 0) {
std::cout << "Succeeding to walk" << std::endl;
- this->position = walk(total.x > 0);
+ this->position = walk(PHYSICS_TICK_MS, total.x > 0);
this->velocity = Vector(0,0);
}
}
--- a/src/proto2/Physics.hh Wed Dec 03 12:09:42 2008 +0000
+++ b/src/proto2/Physics.hh Wed Dec 03 12:21:38 2008 +0000
@@ -196,7 +196,7 @@
* @param right Boolean describing the movement direction.
* @return New position
*/
- Vector walk(bool right);
+ Vector walk(TimeMS, bool right);
/*
* Handle collision. TODO: This is not used. It probably should