--- a/src/PhysicsObject.cc Sat Dec 06 20:56:24 2008 +0000
+++ b/src/PhysicsObject.cc Sat Dec 06 21:02:35 2008 +0000
@@ -114,6 +114,18 @@
// Add gravity to the force queue
forceq.push(world.gravity);
+ // If the object (practically player) has a pivot point add
+ // a force towards that
+ if (pivot != NULL) {
+ Vector direction(pivot->getPosition()-position);
+ float magnitude = pivot->getPivotForce(this);
+ float length = direction.length();
+ if (length > 0) {
+ direction = direction / length * magnitude;
+ forceq.push(direction);
+ }
+ }
+
// Go trough every force in the queue
Force total;
while (!forceq.empty()) {
@@ -322,6 +334,10 @@
this->shape = shape;
}
+void PhysicsObject::setPivot (PhysicsObject *pivot) {
+ this->pivot = pivot;
+}
+
void PhysicsObject::tick (TimeMS tick_length) {
this->updatePosition(tick_length);
}
@@ -356,6 +372,8 @@
}
}
+float PhysicsObject::getPivotForce (PhysicsObject *bob) { return 0.0; }
+
void PhysicsObject::draw(CL_GraphicContext *gc) {
CL_Quad player(
(position+shape[0]).x, (position+shape[0]).y,