diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-01 10:49:36 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-01 10:49:36 +0000 |
commit | 73911893133028a855931b037ed4e90217d5503a (patch) | |
tree | 24eaed10128754db9436ea9bd333d169f041cc0c | |
parent | 768cf33e1b66994379ac757aae0589bee83a2e7f (diff) | |
download | mana-73911893133028a855931b037ed4e90217d5503a.tar.gz mana-73911893133028a855931b037ed4e90217d5503a.tar.bz2 mana-73911893133028a855931b037ed4e90217d5503a.tar.xz mana-73911893133028a855931b037ed4e90217d5503a.zip |
Third time is the charm; changed sprite direction code again.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/being.cpp | 23 | ||||
-rw-r--r-- | src/being.h | 14 | ||||
-rw-r--r-- | src/game.cpp | 20 |
4 files changed, 31 insertions, 33 deletions
@@ -1,3 +1,10 @@ +2007-01-01 Guillaume Melquiond <guillaume.melquiond@gmail.com> + + * src/being.h, src/being.cpp, src/game.cpp: Made getSpriteDirection + public and trivial. Removed getDirection: its return value does not + match what the user sees, so its use is dubious from a user-interface + point of view. + 2006-12-31 Guillaume Melquiond <guillaume.melquiond@gmail.com> * src/being.h, src/being.cpp, src/joystick.h: Scrapped static const diff --git a/src/being.cpp b/src/being.cpp index 1018b8e1..68c670fd 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), - mFaceDirection(DOWN), mDirection(DOWN), + mSpriteDirection(DIRECTION_DOWN), mDirection(DOWN), mMap(NULL), mHairStyle(0), mHairColor(0), mSpeechTime(0), @@ -372,24 +372,12 @@ Being::setDirection(Uint8 direction) return; // if the direction does not change much, keep the common component - mFaceDirection = mDirection & direction; + int mFaceDirection = mDirection & direction; if (!mFaceDirection) mFaceDirection = direction; mDirection = direction; - SpriteDirection dir = getSpriteDirection(); - for (int i = 0; i < VECTOREND_SPRITE; i++) - { - if (mSprites[i] != NULL) - mSprites[i]->setDirection(dir); - } -} - -SpriteDirection -Being::getSpriteDirection() const -{ SpriteDirection dir; - if (mFaceDirection & UP) { dir = DIRECTION_UP; @@ -406,8 +394,13 @@ Being::getSpriteDirection() const { dir = DIRECTION_LEFT; } + mSpriteDirection = dir; - return dir; + for (int i = 0; i < VECTOREND_SPRITE; i++) + { + if (mSprites[i] != NULL) + mSprites[i]->setDirection(dir); + } } void diff --git a/src/being.h b/src/being.h index 6eca252c..f9287b65 100644 --- a/src/being.h +++ b/src/being.h @@ -299,9 +299,10 @@ class Being : public Sprite setAction(Uint8 action); /** - * Returns the current direction. + * Returns the direction the being is facing. */ - Uint8 getDirection() const { return mDirection; } + SpriteDirection getSpriteDirection() const + { return SpriteDirection(mSpriteDirection); } /** * Sets the current direction. @@ -351,18 +352,13 @@ class Being : public Sprite void setPath(const Path &path, int mod = 1024); - /** - * Returns the sprite direction of this being. - */ - SpriteDirection - getSpriteDirection() const; - Uint16 mId; /**< Unique being id */ Uint8 mSex; /**< Character's gender */ Uint16 mWeapon; /**< Weapon picture id */ Uint16 mWalkSpeed; /**< Walking speed */ Uint16 mSpeedModifier; /**< Modifier to keep course on sync (1024 = normal speed) */ - Uint8 mFaceDirection,mDirection;/**< Facing direction */ + Uint8 mSpriteDirection; /**< Facing direction */ + Uint8 mDirection; /**< Walking direction */ Map *mMap; /**< Map on which this being resides */ SpriteIterator mSpriteIterator; diff --git a/src/game.cpp b/src/game.cpp index 21b6008e..f708fabf 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -489,15 +489,17 @@ void Game::handleInput() // If none below the player, try the tile in front of // the player - if (!item) { - if (player_node->getDirection() & Being::UP) - y--; - if (player_node->getDirection() & Being::DOWN) - y++; - if (player_node->getDirection() & Being::LEFT) - x--; - if (player_node->getDirection() & Being::RIGHT) - x++; + if (!item) + { + // Temporary until tile-based picking is removed. + switch (player_node->getSpriteDirection()) + { + case DIRECTION_UP : --y; break; + case DIRECTION_DOWN : ++y; break; + case DIRECTION_LEFT : --x; break; + case DIRECTION_RIGHT: ++x; break; + default: break; + } item = floorItemManager->findByCoordinates(x, y); } |