--- a/src/proto2/Physics.cc Tue Dec 02 00:24:01 2008 +0000
+++ b/src/proto2/Physics.cc Tue Dec 02 00:47:14 2008 +0000
@@ -42,19 +42,28 @@
world.addObject(this);
}
+/**
+ * Player walks on floor.
+ */
Vector PhysicsObject::walk (bool right) {
- float deltaX = right ? 1 : -1;
+ float deltaX = right ? 1 : -1; // which way we are walking
Vector reached = this->position;
+ // Is there upward ramp
if(!possibleLocation(position+Vector(deltaX, 0))) {
+ // Yes. Then we check n pixels up
for(int i = 1; i < 3; i++) {
if(possibleLocation(position+Vector(deltaX, -i))) {
+ // and when there is finally EMPTY, we can walk
reached = position+Vector(deltaX, -i);
break;
}
}
} else {
+ // Or downward ramp
for(int i = 0; i < 3; i++) {
+ // And when there is finally ground we can step on it
+ // If there is no gound we still step there, but will fall down
if(possibleLocation(position+Vector(deltaX, i))) {
reached = position+Vector(deltaX, i);
} else {
@@ -62,6 +71,7 @@
}
}
}
+ // And we return where we got
return reached;
}