--- a/src/proto2/Physics.cc Mon Dec 01 22:36:32 2008 +0000
+++ b/src/proto2/Physics.cc Mon Dec 01 22:58:15 2008 +0000
@@ -144,6 +144,10 @@
// hack. I think we should handle walking from the collision
// detection code.
+ if (this->velocity.sqrLength() < PLAYER_MIN_SPEED * PLAYER_MIN_SPEED) {
+ this->inAir = !world.collides(this->position+shape[2]+Vector(0, 1));
+ }
+
if (!this->inAir) {
if (total.x != 0)
this->position = walk(total.x > 0);
@@ -176,7 +180,7 @@
}
reached = reached - unitVector; // Return to last point
collided = true;
- if (this->velocity.length() < PLAYER_MIN_SPEED) {
+ if (this->velocity.sqrLength() < PLAYER_MIN_SPEED * PLAYER_MIN_SPEED) {
this->inAir = false;
this->velocity = Vector(0,0);
}
--- a/src/proto2/Vector.hh Mon Dec 01 22:36:32 2008 +0000
+++ b/src/proto2/Vector.hh Mon Dec 01 22:58:15 2008 +0000
@@ -68,7 +68,10 @@
// Other operations
T length() const {
- return sqrt((this->x * this->x) + (this->y * this->y));
+ return sqrt(sqrLength());
+ }
+ T sqrLength() const {
+ return (this->x * this->x) + (this->y * this->y);
}
_Vector roundToInt() const {
return _Vector((int)(x), (int)(y));