From 19bc88f34713968864922f8f3f2342d10c4f4dbd Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Thu, 2 Feb 2012 17:42:31 +0100 Subject: Fixed player's character direction. Made the player's character look at where it is going even when using the keyboard, by setting its direction after getting the actual destination, and not before. I also used the lookAt() function to avoid yet another custom way of setting the direction. Reviewed-by: Erik Schilling --- src/being.h | 4 +++- src/localplayer.cpp | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/being.h b/src/being.h index 6464090c..84c159b7 100644 --- a/src/being.h +++ b/src/being.h @@ -443,7 +443,9 @@ class Being : public ActorSprite, public EventListener /** * Make the being look at a given pixel position. */ - void lookAt(const Vector &destPos); + void lookAt(const Vector &destVec); + void lookAt(const Position &destPos) + { lookAt(Vector(destPos.x, destPos.y)); } protected: /** diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 8d6ad542..efdcaa60 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -546,6 +546,7 @@ void LocalPlayer::nextTile(unsigned char dir = 0) if ((int)pos.x != destination.x || (int)pos.y != destination.y) { + lookAt(destination); setDestination(destination.x, destination.y); } else if (dir != mDirection) @@ -759,9 +760,6 @@ void LocalPlayer::startWalking(unsigned char dir) if (dir & RIGHT) dx++; - // Update the direction when the walk just start - setDirection(dir); - nextTile(dir); } -- cgit v1.2.3-60-g2f50