diff options
author | Joe Robinson <joe@lc8n.com> | 2010-12-21 18:00:21 +0000 |
---|---|---|
committer | Luke Bratch <l_bratch@yahoo.co.uk> | 2010-12-21 18:00:21 +0000 |
commit | c04ccc9cc3aa91c634880cbfd2d77b58d68189ad (patch) | |
tree | adf3565be9fa62b6c1092e53a621c69e756ad77b /Player.cpp | |
parent | 610c22ab2bf4ac2c6abbce7991436a910dafe5f6 (diff) |
Implement crouching
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; +} |