Mui. Sienet.
authorsaiam
Mon, 24 Nov 2008 21:32:41 +0000
changeset 99 c9b96dcfe4ee
parent 98 606c419e42a7
child 100 29c3d91cad82
Mui. Sienet.
src/proto2/Physics.cc
src/proto2/Vector.hh
--- a/src/proto2/Physics.cc	Mon Nov 24 21:24:17 2008 +0000
+++ b/src/proto2/Physics.cc	Mon Nov 24 21:32:41 2008 +0000
@@ -341,9 +341,9 @@
  */
 void PhysicsObject::bounce (Vector normal) {
     Vector tangent(normal.y, -normal.x);
-	Vector tprojection = velocity * tangent / tangent.length();
-	Vector nprojection = velocity * normal / normal.length();
-	velocity = tprojection - nprojection;
+    Vector tprojection = (velocity * tangent) / tangent.length();
+    Vector nprojection = (velocity * normal) / normal.length();
+    velocity = tprojection - nprojection;
 }
 
 /*bool PhysicsWorld::collided (Vector oldPos, Vector newPos) {
--- a/src/proto2/Vector.hh	Mon Nov 24 21:24:17 2008 +0000
+++ b/src/proto2/Vector.hh	Mon Nov 24 21:32:41 2008 +0000
@@ -37,6 +37,9 @@
     _Vector operator*(const T &d) const {
         return _Vector(this->x*d, this->y*d);
     }
+    T operator*(const _Vector &v) const {
+        return (this->x*v.x + this->y*v.y);
+    }
     _Vector operator/(const T &d) const {
         return _Vector(this->x/d, this->y/d);
     }