--- a/src/proto2/Physics.cc Mon Dec 01 23:39:37 2008 +0000
+++ b/src/proto2/Physics.cc Mon Dec 01 23:43:05 2008 +0000
@@ -54,7 +54,7 @@
}
}
} else {
- for(int i = 0; i < 3; i++) {
+ for(int i = 0; i < 3; i++) {
if(possibleLocation(position+Vector(deltaX, i))) {
reached = position+Vector(deltaX, i);
} else {
@@ -66,11 +66,26 @@
}
-void PhysicsObject::jump () {
+/**
+ * Makes the player jump in the air.
+ * @param direction -1: jump left, 0: jump up, 1: jump right
+ */
+void PhysicsObject::jump (int direction) {
// Jump only if player is "on the ground"
if (!this->inAir) {
velocity.y = -100;
- velocity.x += facingRight ? 20 : -20;
+ switch (direction) {
+ case 1:
+ velocity.x += 20;
+ break;
+ case -1:
+ velocity.x -= 20;
+ break;
+ case 0:
+ break;
+ default:
+ throw std::logic_error("Invalid jump direction");
+ }
inAir = true;
}
}