summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp34
-rw-r--r--src/being.h2
2 files changed, 11 insertions, 25 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 55a321ab..08f5a491 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -60,7 +60,7 @@ Being::Being(Uint16 id, Uint16 job, Map *map):
mWeapon(0),
mWalkSpeed(150),
mSpeedModifier(1024),
- mOldDirection(DOWN), mDirection(DOWN),
+ mFaceDirection(DOWN), mDirection(DOWN),
mMap(NULL),
mHairStyle(0), mHairColor(0),
mSpeechTime(0),
@@ -370,10 +370,14 @@ Being::setDirection(Uint8 direction)
{
if (mDirection == direction)
return;
- mOldDirection = mDirection;
+
+ // if the direction does not change much, keep the common component
+ mFaceDirection = mDirection & direction;
+ if (!mFaceDirection)
+ mFaceDirection = direction;
mDirection = direction;
- SpriteDirection dir = getSpriteDirection();
+ SpriteDirection dir = getSpriteDirection();
for (int i = 0; i < VECTOREND_SPRITE; i++)
{
if (mSprites[i] != NULL)
@@ -386,33 +390,15 @@ Being::getSpriteDirection() const
{
SpriteDirection dir;
- // if the direction has not changed much, keep it for the sprite
- if (mOldDirection & mDirection & UP)
- {
- dir = DIRECTION_UP;
- }
- else if (mOldDirection & mDirection & RIGHT)
- {
- dir = DIRECTION_RIGHT;
- }
- else if (mOldDirection & mDirection & DOWN)
- {
- dir = DIRECTION_DOWN;
- }
- else if (mOldDirection & mDirection & LEFT)
- {
- dir = DIRECTION_LEFT;
- }
- // otherwise, use only the new direction
- else if (mDirection & UP)
+ if (mFaceDirection & UP)
{
dir = DIRECTION_UP;
}
- else if (mDirection & RIGHT)
+ else if (mFaceDirection & RIGHT)
{
dir = DIRECTION_RIGHT;
}
- else if (mDirection & DOWN)
+ else if (mFaceDirection & DOWN)
{
dir = DIRECTION_DOWN;
}
diff --git a/src/being.h b/src/being.h
index ff65b034..8bb382ee 100644
--- a/src/being.h
+++ b/src/being.h
@@ -365,7 +365,7 @@ class Being : public Sprite
Uint16 mWeapon; /**< Weapon picture id */
Uint16 mWalkSpeed; /**< Walking speed */
Uint16 mSpeedModifier; /**< Modifier to keep course on sync (1024 = normal speed) */
- Uint8 mOldDirection,mDirection; /**< Facing direction */
+ Uint8 mFaceDirection,mDirection;/**< Facing direction */
Map *mMap; /**< Map on which this being resides */
SpriteIterator mSpriteIterator;