Restore crosshair position after player death.
This commit is contained in:
parent
b5514b6af9
commit
384ab6c486
3 changed files with 8 additions and 0 deletions
|
@ -74,8 +74,10 @@ Game::loop() {
|
||||||
|
|
||||||
mWorld.think(elapsed);
|
mWorld.think(elapsed);
|
||||||
if (mPlayer->getHealth() == 0) {
|
if (mPlayer->getHealth() == 0) {
|
||||||
|
Vector2f pos = mPlayer->getCrosshairPosition();
|
||||||
mWorld.remove(mPlayer);
|
mWorld.remove(mPlayer);
|
||||||
initPlayer();
|
initPlayer();
|
||||||
|
mPlayer->setCrosshairPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
mWorld.step(elapsed);
|
mWorld.step(elapsed);
|
||||||
|
|
|
@ -21,6 +21,11 @@ Player::Player(World& world, Pathfinder& pathfinder,
|
||||||
mDirection(0) {
|
mDirection(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2f
|
||||||
|
Player::getCrosshairPosition() const {
|
||||||
|
return mCrosshairPosition;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the point where to look and shoot at.
|
* Sets the point where to look and shoot at.
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
explicit Player(World& world, Pathfinder& pathfinder,
|
explicit Player(World& world, Pathfinder& pathfinder,
|
||||||
const Vector2f& position);
|
const Vector2f& position);
|
||||||
|
|
||||||
|
Vector2f getCrosshairPosition() const;
|
||||||
void setCrosshairPosition(const Vector2f& position);
|
void setCrosshairPosition(const Vector2f& position);
|
||||||
using Character::pullTrigger;
|
using Character::pullTrigger;
|
||||||
using Character::releaseTrigger;
|
using Character::releaseTrigger;
|
||||||
|
|
Reference in a new issue