diff --git a/source/Game.cpp b/source/Game.cpp index 5c8540e..6bea712 100644 --- a/source/Game.cpp +++ b/source/Game.cpp @@ -74,8 +74,10 @@ Game::loop() { mWorld.think(elapsed); if (mPlayer->getHealth() == 0) { + Vector2f pos = mPlayer->getCrosshairPosition(); mWorld.remove(mPlayer); initPlayer(); + mPlayer->setCrosshairPosition(pos); } mWorld.step(elapsed); diff --git a/source/sprites/Player.cpp b/source/sprites/Player.cpp index 855adcb..7ca50c7 100644 --- a/source/sprites/Player.cpp +++ b/source/sprites/Player.cpp @@ -21,6 +21,11 @@ Player::Player(World& world, Pathfinder& pathfinder, mDirection(0) { } +Vector2f +Player::getCrosshairPosition() const { + return mCrosshairPosition; +} + /** * Sets the point where to look and shoot at. * diff --git a/source/sprites/Player.h b/source/sprites/Player.h index c3ba002..9f50f72 100644 --- a/source/sprites/Player.h +++ b/source/sprites/Player.h @@ -31,6 +31,7 @@ public: explicit Player(World& world, Pathfinder& pathfinder, const Vector2f& position); + Vector2f getCrosshairPosition() const; void setCrosshairPosition(const Vector2f& position); using Character::pullTrigger; using Character::releaseTrigger;