summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-02 23:05:46 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-02 23:05:46 +0000
commit8676da1517a86105e4cb4970fd3a7886f7d0c214 (patch)
tree5c4b3b7748c62d9375799f375e13c4b58a89498a /src/being.cpp
parent8714de88fe9715b5a4014f16d15bc55f8860cdcf (diff)
downloadmana-8676da1517a86105e4cb4970fd3a7886f7d0c214.tar.gz
mana-8676da1517a86105e4cb4970fd3a7886f7d0c214.tar.bz2
mana-8676da1517a86105e4cb4970fd3a7886f7d0c214.tar.xz
mana-8676da1517a86105e4cb4970fd3a7886f7d0c214.zip
Some cleanups, fixes and a small start on a solution for the animated sprite
synchronization problem (resetting all animations).
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp124
1 files changed, 65 insertions, 59 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 13bcb44a..4d106641 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -167,64 +167,63 @@ Being::setMap(Map *map)
void
Being::setAction(Uint8 action)
{
- //if (action != mAction)
+ SpriteAction currentAction = ACTION_STAND;
+ switch (action)
{
- SpriteAction currentAction = ACTION_STAND;
- switch (action)
- {
- case WALK:
- currentAction = ACTION_WALK;
- break;
- case SIT:
- currentAction = ACTION_SIT;
- break;
- case ATTACK:
- if (getType() == MONSTER)
- {
- currentAction = ACTION_DEAD;
- }else{
- switch (getWeapon())
- {
- case 2:
- currentAction = ACTION_ATTACK_BOW;
- break;
- case 1:
- currentAction = ACTION_ATTACK_STAB;
- break;
- case 0:
- currentAction = ACTION_ATTACK;
- break;
- }
- };
- break;
- case MONSTER_ATTACK:
- currentAction = ACTION_ATTACK;
- break;
- case DEAD:
+ case WALK:
+ currentAction = ACTION_WALK;
+ break;
+ case SIT:
+ currentAction = ACTION_SIT;
+ break;
+ case ATTACK:
+ if (getType() == MONSTER)
+ {
currentAction = ACTION_DEAD;
- break;
- default:
- currentAction = ACTION_STAND;
- break;
- }
+ }
+ else {
+ switch (getWeapon())
+ {
+ case 2:
+ currentAction = ACTION_ATTACK_BOW;
+ break;
+ case 1:
+ currentAction = ACTION_ATTACK_STAB;
+ break;
+ case 0:
+ currentAction = ACTION_ATTACK;
+ break;
+ }
+ };
+ break;
+ case MONSTER_ATTACK:
+ currentAction = ACTION_ATTACK;
+ break;
+ case DEAD:
+ currentAction = ACTION_DEAD;
+ break;
+ default:
+ currentAction = ACTION_STAND;
+ break;
+ }
- for (int i = 0; i < VECTOREND_SPRITE; i++)
+ for (int i = 0; i < VECTOREND_SPRITE; i++)
+ {
+ if (mSprites[i] != NULL)
{
- if (mSprites[i] != NULL)
+ if (currentAction == ACTION_ATTACK ||
+ currentAction == ACTION_ATTACK_STAB ||
+ currentAction == ACTION_ATTACK_BOW)
{
- if (currentAction == ACTION_ATTACK ||
- currentAction == ACTION_ATTACK_STAB ||
- currentAction == ACTION_ATTACK_BOW)
- {
- mSprites[i]->play(currentAction, mAttackSpeed);
- }
- else
- {
- mSprites[i]->play(currentAction);
- }
+ mSprites[i]->play(currentAction, mAttackSpeed);
+ }
+ else
+ {
+ mSprites[i]->play(currentAction);
}
}
}
+
mAction = action;
}
@@ -232,29 +231,36 @@ void
Being::setDirection(Uint8 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 (direction & UP)
+ if (mDirection & UP)
{
dir = DIRECTION_UP;
}
- else if (direction & RIGHT)
+ else if (mDirection & RIGHT)
{
dir = DIRECTION_RIGHT;
}
- else if (direction & DOWN)
+ else if (mDirection & DOWN)
{
dir = DIRECTION_DOWN;
}
- else
- {
+ else {
dir = DIRECTION_LEFT;
}
- for (int i = 0; i < VECTOREND_SPRITE; i++)
- {
- if (mSprites[i] != NULL) mSprites[i]->setDirection(dir);
- }
+ return dir;
}
void