diff options
Diffstat (limited to 'Player.cpp')
-rw-r--r-- | Player.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -5,6 +5,7 @@ Player::Player() { health = 100; sprint = false; crouch = 0; + setWeapon(0); } void Player::jump() { @@ -66,3 +67,28 @@ void Player::orient() { int Player::getCrouch() { return crouch; } + +void Player::setWeapon(int weaponNo) { + // Set the current active weapon + weapon = weapons[weaponNo]; +} + +void Player::obtainWeapon(int weaponNo) { + // Add a new weapon to the available weapons + if (numWeapons < 10) { + switch (weaponNo) { + case 0: + weapons[numWeapons] = new Weapon(); + break; + case 1: + weapons[numWeapons] = new Shotgun(); + } + weapon = weapons[numWeapons]; + numWeapons++; + } +} + +void Player::attack() { + // Perform an attack with the current weapon + weapon->attack(); +} |