huoh
authorekku
Thu, 20 Nov 2008 19:52:38 +0000
changeset 80 c21641a487c5
parent 79 295ecb26d8ff
child 81 4a91cf6f5cc7
huoh
src/proto2/Physics.cc
--- a/src/proto2/Physics.cc	Thu Nov 20 19:23:15 2008 +0000
+++ b/src/proto2/Physics.cc	Thu Nov 20 19:52:38 2008 +0000
@@ -51,20 +51,23 @@
     
 //    Engine::log(DEBUG, "physics.update_position") << "position=" << newPosition << ", velocity=" << velocity;
 
-    bool collided = true;
+    bool collided = false;
 
     //goes 1 unit forward every step and check if has hit anything
-    Vector unitVector = newPosition / newPosition.length();
+    Vector unitVector = (newPosition-position) / (newPosition-position).length();
     Vector tmpVector = position;
     Vector reached = position;
     for(int i = 0; i < newPosition.length(); i++) {
         tmpVector += unitVector;
         if(world.getType(tmpVector) != EMPTY) {
+			//Engine::log(DEBUG, "physics.update_position") << "hit something";
             // Then we have hit something
             reached = position + unitVector*(i-1);
-            collided = false;
+            collided = true;
             break;
-        }
+        } else {
+			//Engine::log(DEBUG, "physics.update_position") << "didnt hit";
+		}
     }
 
     // In case of some float error