summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-10-26 00:02:01 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-10-26 00:02:01 +0000
commit050cee64b64aba57de84383c7138c1ad0f4ded55 (patch)
tree7c080b187c9a0b1d6b1435141cfb956c379b3ca4 /src/localplayer.cpp
parent796c2addfb17b57992d304667248873ee26088dc (diff)
downloadmana-client-050cee64b64aba57de84383c7138c1ad0f4ded55.tar.gz
mana-client-050cee64b64aba57de84383c7138c1ad0f4ded55.tar.bz2
mana-client-050cee64b64aba57de84383c7138c1ad0f4ded55.tar.xz
mana-client-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/localplayer.cpp')
-rw-r--r--src/localplayer.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 68648d74..9c1cd743 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -46,7 +46,7 @@
#include "utils/tostring.h"
#include "utils/gettext.h"
-const short walkingKeyboardDelay = 100;
+const short walkingKeyboardDelay = 500;
LocalPlayer *player_node = NULL;
@@ -242,6 +242,7 @@ void LocalPlayer::walk(unsigned char dir)
return;
const Vector &pos = getPosition();
+ int dScaler; // Distance to walk
if (mAction == WALK && !mPath.empty())
{
@@ -273,11 +274,22 @@ void LocalPlayer::walk(unsigned char dir)
(pos.y + dy) / 32, getWalkMask()))
dx = 16 - (int) pos.x % 32;
- // Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(((int) pos.x + dx) / 32,
- ((int) pos.y + dy) / 32, getWalkMask()))
+ // Checks our path up to 5 tiles, if a blocking tile is found
+ // We go to the last good tile, and break out of the loop
+ for (dScaler = 1; dScaler <= 5; dScaler++)
{
- setDestination((int) pos.x + dx, (int) pos.y + dy);
+ if ( (dx || dy) &&
+ !mMap->getWalk( ((int) pos.x + (dx * dScaler)) / 32,
+ ((int) pos.y + (dy * dScaler)) / 32, getWalkMask()) )
+ {
+ dScaler--;
+ break;
+ }
+ }
+
+ if (dScaler >= 0)
+ {
+ setDestination((int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
}
else if (dir)
{
@@ -336,6 +348,20 @@ void LocalPlayer::setWalkingDir(int dir)
}
}
+void LocalPlayer::stopWalking(bool sendToServer)
+{
+ if(mAction == WALK && mWalkingDir){
+ mWalkingDir = 0;
+ mLocalWalkTime = 0;
+ Being::setDestination(getPosition().x,getPosition().y);
+ if (sendToServer)
+ Net::GameServer::Player::walk(getPosition().x, getPosition().y);
+ setAction(STAND);
+ }
+
+ clearPath();
+}
+
void LocalPlayer::toggleSit()
{
if (mLastAction != -1)