#include #include "Player.h" Player::Player() { health = 100; sprint = false; crouch = 0; numWeapons = 0; setWeapon(0); } void Player::jump() { if (!yVel) { incYVel(-JUMP_STRENGTH); } } void Player::kill() { health = 0; // Do resetting stuff } void Player::setSprint(bool s) { sprint = s; } bool Player::getSprint() { return sprint; } int Player::getXVel() { if (sprint) return xVel * SPRINT_MULTIPLYER; else return xVel; } /* Set crouching state 0 = default, not crouching 1 = attempting to stop crouching 2 = crouching */ void Player::setCrouch(int c) { if (c == 2) { crouch = 2; setY(getY() + MARCUS_HEIGHT - CROUCH_HEIGHT); } else if (c == 1) { crouch = 1; } else if (c == 0) { crouch = 0; setY(getY() - MARCUS_HEIGHT + CROUCH_HEIGHT); } } // Override orient to give player crouching void Player::orient() { if (crouch > 0) clipNo = ORIENT_CROUCH; else if (xVel < 0) clipNo = ORIENT_LEFT; else if (xVel > 0) clipNo = ORIENT_RIGHT; else if (yVel < 0) clipNo = ORIENT_BACK; else clipNo = ORIENT_FRONT; } 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(); }