Kimpoominen oikein.
authorekku
Tue, 18 Nov 2008 21:20:35 +0000
changeset 62 c72f8fca1d11
parent 61 d7999511b103
child 63 1969a1447ef9
Kimpoominen oikein.
src/proto2/Physics.cc
--- a/src/proto2/Physics.cc	Tue Nov 18 21:20:07 2008 +0000
+++ b/src/proto2/Physics.cc	Tue Nov 18 21:20:35 2008 +0000
@@ -41,11 +41,14 @@
     
     Engine::log(DEBUG, "physics.update_position") << "position=" << newPosition << ", velocity=" << velocity;
 
-    if (newPosition.x < 0 || (newPosition.x > world.dimensions.x) || (newPosition.y < 0) || (newPosition.y >= world.dimensions.y)) {
+    if (newPosition.x < 0 || (newPosition.x > world.dimensions.x)) {
         // CRASH!
-        this->velocity *= -1;
-
-    } else {
+        this->velocity.x *= -1;
+    }
+	else if(newPosition.y < 0 || (newPosition.y >= world.dimensions.y)) {
+	   this->velocity.y *= -1; 
+	}
+	else {
         this->position = newPosition;
     }
 }