summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-12-29 23:15:54 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-12-29 23:15:54 +0000
commit82a0eab42381e89803d93f6ae1a9cfafd2abb254 (patch)
tree12e7f46ca4f8060626c595c17ffb2c71151cb7cd
parent787f53c8dcd799161bd9a662dc2fe898f1708361 (diff)
downloadmana-82a0eab42381e89803d93f6ae1a9cfafd2abb254.tar.gz
mana-82a0eab42381e89803d93f6ae1a9cfafd2abb254.tar.bz2
mana-82a0eab42381e89803d93f6ae1a9cfafd2abb254.tar.xz
mana-82a0eab42381e89803d93f6ae1a9cfafd2abb254.zip
Improved movement smoothness by avoiding useless changes of sprite direction.
-rw-r--r--ChangeLog5
-rw-r--r--src/being.cpp28
-rw-r--r--src/being.h2
-rw-r--r--src/net/network.cpp2
4 files changed, 32 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index c5e01461..f9327b2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-30 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+
+ * src/being.h, src/being.cpp: Improved movement smoothness by avoiding
+ useless changes of sprite direction.
+
2006-12-29 Guillaume Melquiond <guillaume.melquiond@gmail.com>
* src/gui/connection.cpp: Fixed displaying of progress dialog.
diff --git a/src/being.cpp b/src/being.cpp
index 9cd0af0d..55a321ab 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),
- mDirection(DOWN),
+ mOldDirection(DOWN), mDirection(DOWN),
mMap(NULL),
mHairStyle(0), mHairColor(0),
mSpeechTime(0),
@@ -368,6 +368,9 @@ Being::setAction(Uint8 action)
void
Being::setDirection(Uint8 direction)
{
+ if (mDirection == direction)
+ return;
+ mOldDirection = mDirection;
mDirection = direction;
SpriteDirection dir = getSpriteDirection();
@@ -383,7 +386,25 @@ Being::getSpriteDirection() const
{
SpriteDirection dir;
- if (mDirection & UP)
+ // 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)
{
dir = DIRECTION_UP;
}
@@ -395,7 +416,8 @@ Being::getSpriteDirection() const
{
dir = DIRECTION_DOWN;
}
- else {
+ else
+ {
dir = DIRECTION_LEFT;
}
diff --git a/src/being.h b/src/being.h
index c95cd191..ff65b034 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 mDirection; /**< Facing direction */
+ Uint8 mOldDirection,mDirection; /**< Facing direction */
Map *mMap; /**< Map on which this being resides */
SpriteIterator mSpriteIterator;
diff --git a/src/net/network.cpp b/src/net/network.cpp
index b94c9eb8..6b29ff33 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -148,7 +148,7 @@ void Net::flush()
switch (event.type)
{
case ENET_EVENT_TYPE_CONNECT:
- logger->log("Connected.");
+ logger->log("Connected to port %d.", event.peer->address.port);
// Store any relevant server information here.
event.peer->data = 0;
break;