Mui. Sienet.
--- 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);
}