diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-12-30 10:03:51 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-12-30 10:03:51 +0000 |
commit | a89d148280158e22723496181414f2c3d6ac676b (patch) | |
tree | df994e3429dce894eee55f7b8edf8ca223393f35 /src/being.cpp | |
parent | 82a0eab42381e89803d93f6ae1a9cfafd2abb254 (diff) | |
download | mana-a89d148280158e22723496181414f2c3d6ac676b.tar.gz mana-a89d148280158e22723496181414f2c3d6ac676b.tar.bz2 mana-a89d148280158e22723496181414f2c3d6ac676b.tar.xz mana-a89d148280158e22723496181414f2c3d6ac676b.zip |
Back to four cases when computing sprite direction.
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 34 |
1 files changed, 10 insertions, 24 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; } |