# HG changeset patch # User ekku # Date 1227043946 0 # Node ID 1969a1447ef91575cd58ae03da6b41b3e13b4bc3 # Parent c72f8fca1d1118638315c1b90e5815f42751a3e4 Damped oscillation. diff -r c72f8fca1d11 -r 1969a1447ef9 src/proto2/Physics.cc --- 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;