diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-10-26 00:02:01 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-10-26 00:02:01 +0000 |
commit | 050cee64b64aba57de84383c7138c1ad0f4ded55 (patch) | |
tree | 7c080b187c9a0b1d6b1435141cfb956c379b3ca4 /src/game.cpp | |
parent | 796c2addfb17b57992d304667248873ee26088dc (diff) | |
download | mana-050cee64b64aba57de84383c7138c1ad0f4ded55.tar.gz mana-050cee64b64aba57de84383c7138c1ad0f4ded55.tar.bz2 mana-050cee64b64aba57de84383c7138c1ad0f4ded55.tar.xz mana-050cee64b64aba57de84383c7138c1ad0f4ded55.zip |
Pixel-accurate and fluently animated keyboard movement by Kage Jittai - albeit not flawless it is still a big improvement.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp index fc16e1ea..901b8dea 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -787,7 +787,24 @@ void Game::handleInput() direction |= Being::RIGHT; } - player_node->setWalkingDir(direction); + // First if player is pressing key for the direction he is already going + if (direction == player_node->getWalkingDir()) + { + player_node->setWalkingDir(direction); + } + // Else if he is pressing a key, and its different from what he has + // been pressing, stop (do not send this stop to the server) and + // start in the new direction + else if (direction && direction != player_node->getWalkingDir()) + { + player_node->stopWalking(false); + player_node->setWalkingDir(direction); + } + // Else, he is not pressing a key, stop (sending to server) + else + { + player_node->stopWalking(true); + } // Target the nearest player if 'q' is pressed if (keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER)) |