--- a/src/PhysicsObject.cc Mon Dec 08 17:30:17 2008 +0000
+++ b/src/PhysicsObject.cc Mon Dec 08 17:39:01 2008 +0000
@@ -412,8 +412,8 @@
shouldDelete = true;
}
-bool PhysicsObject::isDestroyed (void) {
- return !alive;
+bool PhysicsObject::isAlive (void) {
+ return alive;
}
bool PhysicsObject::removeIfDestroyed (void) {
--- a/src/PhysicsObject.hh Mon Dec 08 17:30:17 2008 +0000
+++ b/src/PhysicsObject.hh Mon Dec 08 17:39:01 2008 +0000
@@ -79,14 +79,14 @@
* Makes the player jump in the air.
* @param direction -1: jump left, 0: jump up, 1: jump right
*/
- void jump(int direction);
+ void jump (int direction);
/**
* Handle ground-bounce
*
* @param normal Normal vector relative to which to bounce
*/
- void bounce(Vector normal);
+ void bounce (Vector normal);
/**
* Called on network clients to sync state from server
@@ -97,7 +97,7 @@
* @param facingRight New facingRight value
* @param aim New aim
*/
- virtual void updatePhysics(Vector position, Vector velocity, bool inAir, FacingDirection facing, float aim);
+ virtual void updatePhysics (Vector position, Vector velocity, bool inAir, FacingDirection facing, float aim);
/**
* Put object to the objects list so that its movement will be calculated.
@@ -119,7 +119,7 @@
/**
* Handle player movement and apply forces.
*/
- void updatePosition(TimeMS dt);
+ void updatePosition (TimeMS dt);
// TODO: Should these be moved to PhysicsWorld?
/**
@@ -128,7 +128,7 @@
* @param force Force to integrate
* @param dt Time intervall
*/
- void integrate(Force force, TimeMS dt, Vector &posAfterTick, Vector &velAfterTick);
+ void integrate (Force force, TimeMS dt, Vector &posAfterTick, Vector &velAfterTick);
/**
* Evaluate the value of the derivative at given time
@@ -137,7 +137,7 @@
* @param dt Time
* @param d Previous derivative
*/
- Derivative evaluate(Force force, TimeMS dt, Derivative &d, const Vector &posAfterTick, const Vector &velAfterTick);
+ Derivative evaluate (Force force, TimeMS dt, Derivative &d, const Vector &posAfterTick, const Vector &velAfterTick);
/**
* Return object acceleration with given force.
@@ -145,7 +145,7 @@
* @param force Force
* @return Acceleration
*/
- Vector acceleration(const Force &force);
+ Vector acceleration (const Force &force);
/**
* Handle ground movement.
@@ -153,8 +153,8 @@
* @param right Boolean describing the movement direction.
* @return New position
*/
- void walk(TimeMS, bool right);
- Vector walk_one_step(float, bool);
+ void walk (TimeMS, bool right);
+ Vector walk_one_step (float, bool);
public:
/**
@@ -173,7 +173,7 @@
* Checks if it is possible for the object to be in the given
* location.
*/
- bool possibleLocation(Vector loc);
+ bool possibleLocation (Vector loc);
/**
* Get current object position.
@@ -208,14 +208,14 @@
*
* @return Velocity vector
*/
- Vector getVelocity() const;
+ Vector getVelocity (void) const;
/**
* Return object shape.
*
* @return Polygon points
*/
- const std::vector<Vector>& getShape() const;
+ const std::vector<Vector>& getShape (void) const;
/**
* Set object shape.
@@ -251,7 +251,7 @@
/*
* Had the object been destroyed?
*/
- bool isDestroyed (void);
+ bool isAlive (void);
/**
* Delete ourselves if we've been destroyed and return true, else return false
--- a/src/Player.cc Mon Dec 08 17:30:17 2008 +0000
+++ b/src/Player.cc Mon Dec 08 17:39:01 2008 +0000
@@ -114,6 +114,10 @@
}
void LocalPlayer::handleInput (PlayerInput input, TimeMS dt) {
+ // if we are dead, we can't do anything
+ if (!isAlive())
+ return;
+
// Movement force, vertical is always zero
Vector move_force = Vector(0, 0);
@@ -230,16 +234,19 @@
}
void Player::takeDamage (Health damage) {
- this->health -= damage;
+ health -= damage;
- if (this->health <= 0)
- this->disable();
+ if (health <= 0)
+ disable();
Engine::log(DEBUG, "player.take_damage") << this << ": damage=" << damage << ", health=" << health;
}
void Player::draw (Graphics *g, PixelCoordinate camera) {
CL_GraphicContext *gc = g->get_gc();
+
+ if (!isAlive())
+ return;
// animation indexes
int aim_img_idx = (int)((1 - (getAim() + KG_PI / 2) / KG_PI) * img_num_aim);
@@ -290,7 +297,7 @@
Player::draw(g, camera);
// display weapon name?
- if (displayWeapon && getCurrentWeapon()) {
+ if (isAlive() && displayWeapon && getCurrentWeapon()) {
const std::string weaponName = getCurrentWeapon()->getName();
PixelCoordinate pc = getCoordinate() - camera;