summaryrefslogtreecommitdiff
path: root/Player.cpp
diff options
context:
space:
mode:
authorJoe Robinson <joe@lc8n.com>2011-03-08 15:14:57 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2011-03-08 15:14:57 +0000
commitc12fcf8e7663c20e2c2c0696fb35a7059b83127a (patch)
tree67eaa0be96e058aae54e4cf16aa0735d1a7b90f2 /Player.cpp
parent78cab811b677f05a6447aafe2fb8658ecb2c573b (diff)
Implement weapons
Diffstat (limited to 'Player.cpp')
-rw-r--r--Player.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/Player.cpp b/Player.cpp
index 09d1743..5995e4f 100644
--- a/Player.cpp
+++ b/Player.cpp
@@ -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();
+}