diff options
Diffstat (limited to 'Player.cpp')
-rw-r--r-- | Player.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -4,6 +4,7 @@ Player::Player() { health = 100; sprint = false; + crouch = 0; } void Player::jump() { @@ -31,3 +32,37 @@ int Player::getXVel() { 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; +} |