Added bind to swap Gadgets with 'F'.

This commit is contained in:
Felix Ableitner 2013-07-13 00:01:57 +02:00
parent 8bee607981
commit cb11a22bff
4 changed files with 14 additions and 3 deletions

View file

@ -172,6 +172,9 @@ Game::keyUp(const sf::Event& event) {
case sf::Keyboard::D: case sf::Keyboard::D:
mPlayer->setDirection(Player::Direction::RIGHT, true); mPlayer->setDirection(Player::Direction::RIGHT, true);
break; break;
case sf::Keyboard::F:
mPlayer->swapGadgets();
break;
default: default:
break; break;
} }

View file

@ -220,6 +220,12 @@ Character::selectSecondWeapon() {
mActiveWeapon = mSecondWeapon; mActiveWeapon = mSecondWeapon;
} }
int
Character::getHealth() const {
return mCurrentHealth;
}
void void
Character::setLeftGadget(std::shared_ptr<Gadget> gadget) { Character::setLeftGadget(std::shared_ptr<Gadget> gadget) {
mLeftGadget = gadget; mLeftGadget = gadget;
@ -250,7 +256,7 @@ Character::getRightGadgetName() const {
return mRightGadget->getName(); return mRightGadget->getName();
} }
int void
Character::getHealth() const { Character::swapGadgets() {
return mCurrentHealth; std::swap(mLeftGadget, mRightGadget);
} }

View file

@ -63,6 +63,7 @@ protected:
void useRightGadget(); void useRightGadget();
std::string getLeftGadgetName() const; std::string getLeftGadgetName() const;
std::string getRightGadgetName() const; std::string getRightGadgetName() const;
void swapGadgets();
protected: protected:

View file

@ -50,6 +50,7 @@ public:
using Character::getHealth; using Character::getHealth;
using Character::getLeftGadgetName; using Character::getLeftGadgetName;
using Character::getRightGadgetName; using Character::getRightGadgetName;
using Character::swapGadgets;
private: private:
void onThink(int elapsed) override; void onThink(int elapsed) override;