summaryrefslogtreecommitdiff
path: root/src/resources/action.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-01-21 23:23:16 +0200
committerAndrei Karas <akaras@inbox.ru>2011-01-21 23:23:16 +0200
commit63112267be277e38224b510ec5745421dd7d4917 (patch)
treeab3ae7990cb49d61382bd0cd225fbe53d329f4a0 /src/resources/action.cpp
parent05ea95733e9ec89626e08989e0688e73d1408d3a (diff)
downloadplus-63112267be277e38224b510ec5745421dd7d4917.tar.gz
plus-63112267be277e38224b510ec5745421dd7d4917.tar.bz2
plus-63112267be277e38224b510ec5745421dd7d4917.tar.xz
plus-63112267be277e38224b510ec5745421dd7d4917.zip
Add diagonal animations.
New animation names: upleft, upright, downleft, downright Tested atleast at mobs.
Diffstat (limited to 'src/resources/action.cpp')
-rw-r--r--src/resources/action.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index 923aa72c9..b8cfde611 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -22,6 +22,7 @@
#include "resources/action.h"
#include "resources/animation.h"
+#include "resources/spritedef.h"
#include "utils/dtor.h"
@@ -38,10 +39,19 @@ Animation *Action::getAnimation(int direction) const
{
Animations::const_iterator i = mAnimations.find(direction);
- // When the given direction is not available, return the first one.
- // (either DEFAULT, or more usually DOWN).
if (i == mAnimations.end())
- i = mAnimations.begin();
+ {
+ if (direction == DIRECTION_UPLEFT || direction == DIRECTION_UPRIGHT)
+ direction = DIRECTION_UP;
+ else if (direction == DIRECTION_DOWNLEFT || direction == DIRECTION_DOWNRIGHT)
+ direction = DIRECTION_DOWN;
+ i = mAnimations.find(direction);
+
+ // When the given direction is not available, return the first one.
+ // (either DEFAULT, or more usually DOWN).
+ if (i == mAnimations.end())
+ i = mAnimations.begin();
+ }
return (i == mAnimations.end()) ? NULL : i->second;
}