--- a/src/PhysicsObject.cc Sun Dec 07 21:18:09 2008 +0000
+++ b/src/PhysicsObject.cc Sun Dec 07 21:34:12 2008 +0000
@@ -4,9 +4,9 @@
#include <cmath>
-PhysicsObject::PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity, bool enabled) :
+PhysicsObject::PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity, ObjectType type, bool enabled) :
world(world), position(position), velocity(velocity), mass(mass), inAir(true), aim(0), facing(FACING_RIGHT),
- alive(false), shouldDelete(false), pivot(NULL)
+ alive(false), shouldDelete(false), type(type), pivot(NULL)
{
if (enabled)
enable();
@@ -203,7 +203,6 @@
}
if (collided)
break;
-// reached += unitVector;
}
--- a/src/PhysicsObject.hh Sun Dec 07 21:18:09 2008 +0000
+++ b/src/PhysicsObject.hh Sun Dec 07 21:34:12 2008 +0000
@@ -14,6 +14,8 @@
// Type definitions
typedef Vector Force;
+
+enum ObjectType { PLAYER, PROJECTILE, ROPE };
enum FacingDirection {
FACING_LEFT,
@@ -37,11 +39,13 @@
bool alive;
bool shouldDelete;
+
+ ObjectType type;
PhysicsObject *pivot;
PhysicsObject(PhysicsWorld &world, float mass, Vector position,
- Vector velocity, bool enabled = true);
+ Vector velocity, ObjectType type, bool enabled = true);
virtual ~PhysicsObject (void);
--- a/src/Player.cc Sun Dec 07 21:18:09 2008 +0000
+++ b/src/Player.cc Sun Dec 07 21:34:12 2008 +0000
@@ -20,7 +20,7 @@
const int img_width = 17;
Player::Player(GameState &state, Vector position, bool visible) :
- PhysicsObject(state.world, PLAYER_MASS, position, Vector(0, 0)), state(state), visible(visible),
+ PhysicsObject(state.world, PLAYER_MASS, position, Vector(0, 0), PLAYER), state(state), visible(visible),
weapons(buildWeaponsList()), selectedWeapon(0), animation_step(0), rope(*this)
{
// XXX: populate weapons from somewhere else
--- a/src/Projectile.cc Sun Dec 07 21:18:09 2008 +0000
+++ b/src/Projectile.cc Sun Dec 07 21:34:12 2008 +0000
@@ -3,7 +3,8 @@
#include "Timer.hh"
Projectile::Projectile (GameState &state, Vector position, Vector velocity, bool visible, float explosionRadius, float radius, TickCount age) :
- PhysicsObject(state.world, PLAYER_MASS, position, velocity), state(state), visible(visible), explosionRadius(explosionRadius), radius(radius), age(age) {
+ PhysicsObject(state.world, PLAYER_MASS, position, velocity, PROJECTILE), state(state), visible(visible), explosionRadius(explosionRadius), radius(radius), age(age)
+{
birth_tick = world.tick_timer.get_ticks();
// Don't think these are needed anymore
std::vector<Vector> shape(4);
--- a/src/Rope.cc Sun Dec 07 21:18:09 2008 +0000
+++ b/src/Rope.cc Sun Dec 07 21:34:12 2008 +0000
@@ -6,7 +6,7 @@
#include <stdexcept>
Rope::Rope(Player &player) :
- PhysicsObject(player.state.world, ROPE_MASS, Vector(0,0), Vector(0,0), false), player(player), state(ROPE_FOLDED)
+ PhysicsObject(player.state.world, ROPE_MASS, Vector(0,0), Vector(0,0), ROPE, false), player(player), state(ROPE_FOLDED)
{
// XXX: better shape
std::vector<Vector> shape(4);