Damped oscillation.
--- a/src/proto2/Physics.cc Tue Nov 18 21:20:35 2008 +0000
+++ b/src/proto2/Physics.cc Tue Nov 18 21:32:26 2008 +0000
@@ -43,10 +43,18 @@
if (newPosition.x < 0 || (newPosition.x > world.dimensions.x)) {
// CRASH!
- this->velocity.x *= -1;
+ this->velocity.x *= -0.5;
+
+ // If the velocity drops under some fixed constant we decide it is zero.
+ // This is to prevent the object from bouncing eternally.
+ if(this->velocity.x < 0.1)
+ this->velocity.x = 0;
}
else if(newPosition.y < 0 || (newPosition.y >= world.dimensions.y)) {
- this->velocity.y *= -1;
+ this->velocity.y *= -0.3;
+
+ if(this->velocity.y < 0.1)
+ this->velocity.y = 0;
}
else {
this->position = newPosition;