diff --git a/source/Game.cpp b/source/Game.cpp index 5d7a172..3411313 100644 --- a/source/Game.cpp +++ b/source/Game.cpp @@ -172,6 +172,9 @@ Game::keyUp(const sf::Event& event) { case sf::Keyboard::D: mPlayer->setDirection(Player::Direction::RIGHT, true); break; + case sf::Keyboard::F: + mPlayer->swapGadgets(); + break; default: break; } diff --git a/source/abstract/Character.cpp b/source/abstract/Character.cpp index 7af8b09..8b6a8cb 100644 --- a/source/abstract/Character.cpp +++ b/source/abstract/Character.cpp @@ -220,6 +220,12 @@ Character::selectSecondWeapon() { mActiveWeapon = mSecondWeapon; } +int +Character::getHealth() const { + return mCurrentHealth; +} + + void Character::setLeftGadget(std::shared_ptr gadget) { mLeftGadget = gadget; @@ -250,7 +256,7 @@ Character::getRightGadgetName() const { return mRightGadget->getName(); } -int -Character::getHealth() const { - return mCurrentHealth; +void +Character::swapGadgets() { + std::swap(mLeftGadget, mRightGadget); } diff --git a/source/abstract/Character.h b/source/abstract/Character.h index 513fef4..d727fd7 100644 --- a/source/abstract/Character.h +++ b/source/abstract/Character.h @@ -63,6 +63,7 @@ protected: void useRightGadget(); std::string getLeftGadgetName() const; std::string getRightGadgetName() const; + void swapGadgets(); protected: diff --git a/source/sprites/Player.h b/source/sprites/Player.h index a62900d..1d0ea65 100644 --- a/source/sprites/Player.h +++ b/source/sprites/Player.h @@ -50,6 +50,7 @@ public: using Character::getHealth; using Character::getLeftGadgetName; using Character::getRightGadgetName; + using Character::swapGadgets; private: void onThink(int elapsed) override;