Added PhysicsObject* attribute to onCollision
authorsaiam
Sun, 07 Dec 2008 23:27:20 +0000
changeset 272 97de051edbcf
parent 271 bf6784a95b08
child 273 eeb699e1d908
Added PhysicsObject* attribute to onCollision
src/PhysicsObject.cc
src/PhysicsObject.hh
src/Player.cc
src/Projectile.cc
src/Projectile.hh
--- a/src/PhysicsObject.cc	Sun Dec 07 23:10:30 2008 +0000
+++ b/src/PhysicsObject.cc	Sun Dec 07 23:27:20 2008 +0000
@@ -224,7 +224,7 @@
         this->position = newPosition;
 
         // the following may delete this object, so it must be the last thing called
-        onCollision(collisionPoint);
+        onCollision(collisionPoint, NULL);
 
         return;
     }
--- a/src/PhysicsObject.hh	Sun Dec 07 23:10:30 2008 +0000
+++ b/src/PhysicsObject.hh	Sun Dec 07 23:27:20 2008 +0000
@@ -154,7 +154,10 @@
     /**
      * Define object behaviour on collisions.
      */
-    virtual void onCollision (Vector collisionPoint) {}
+    virtual void onCollision (Vector collisionPoint, PhysicsObject *other) {}
+
+public:
+    PhysicsWorld &world;
 
     /**
      * Checks if it is possible for the object to be in the given
@@ -162,9 +165,6 @@
      */
     bool possibleLocation(Vector loc);
 
-public:
-    PhysicsWorld &world;
-
     /**
      * Get current object position.
      *
--- a/src/Player.cc	Sun Dec 07 23:10:30 2008 +0000
+++ b/src/Player.cc	Sun Dec 07 23:27:20 2008 +0000
@@ -40,9 +40,9 @@
     collision_elasticity = PLAYER_COLLISION_ELASTICITY;
 }
 
-void Player::handleDig (Vector position, float radius) {
+void Player::handleDig (Vector pos, float radius) {
     // calculate new position and velocity
-    Vector digPosition = position + getDirection() * PROJECTILE_START_DISTANCE;
+    Vector digPosition = pos + getDirection() * PROJECTILE_START_DISTANCE;
     
     // remove directly
     world.removeGround(digPosition, radius);
--- a/src/Projectile.cc	Sun Dec 07 23:10:30 2008 +0000
+++ b/src/Projectile.cc	Sun Dec 07 23:27:20 2008 +0000
@@ -49,7 +49,7 @@
     destroy();
 }
 
-void Projectile::onCollision (Vector collisionPoint) {
+void Projectile::onCollision (Vector collisionPoint, PhysicsObject *other) {
     onDestroy(collisionPoint, true);
 }
 
--- a/src/Projectile.hh	Sun Dec 07 23:10:30 2008 +0000
+++ b/src/Projectile.hh	Sun Dec 07 23:27:20 2008 +0000
@@ -80,7 +80,7 @@
     /**
      * Call onDestroy, removingGround
      */
-    virtual void onCollision (Vector collisionPoint);
+    virtual void onCollision (Vector collisionPoint, PhysicsObject *other);
 
     /**
      * If we have expired, call onDestory and removeGround