summaryrefslogtreecommitdiff
path: root/src/animatedsprite.h
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2006-08-01 19:05:34 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2006-08-01 19:05:34 +0000
commit8714de88fe9715b5a4014f16d15bc55f8860cdcf (patch)
tree9bd100d9d50bcf1357be375ba7b61fd4d136ce54 /src/animatedsprite.h
parent7b599fad6cdbaa40f1cb496218dcd5546de7f520 (diff)
downloadmana-8714de88fe9715b5a4014f16d15bc55f8860cdcf.tar.gz
mana-8714de88fe9715b5a4014f16d15bc55f8860cdcf.tar.bz2
mana-8714de88fe9715b5a4014f16d15bc55f8860cdcf.tar.xz
mana-8714de88fe9715b5a4014f16d15bc55f8860cdcf.zip
animations and directions are now passed and stored as enums and no longer as strings.
Diffstat (limited to 'src/animatedsprite.h')
-rw-r--r--src/animatedsprite.h51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/animatedsprite.h b/src/animatedsprite.h
index 4ef1d9f7..16b30077 100644
--- a/src/animatedsprite.h
+++ b/src/animatedsprite.h
@@ -34,6 +34,33 @@ class Action;
class Graphics;
class Spriteset;
+enum SpriteAction
+{
+ ACTION_DEFAULT = 0,
+ ACTION_STAND,
+ ACTION_WALK,
+ ACTION_RUN,
+ ACTION_ATTACK,
+ ACTION_ATTACK_SWING,
+ ACTION_ATTACK_STAB,
+ ACTION_ATTACK_BOW,
+ ACTION_ATTACK_THROW,
+ ACTION_CAST_MAGIC,
+ ACTION_USE_ITEM,
+ ACTION_SIT,
+ ACTION_SLEEP,
+ ACTION_HURT,
+ ACTION_DEAD
+};
+
+enum SpriteDirection
+{
+ DIRECTION_DOWN = 0,
+ DIRECTION_UP,
+ DIRECTION_LEFT,
+ DIRECTION_RIGHT
+};
+
/**
* Defines a class to load an animation.
*/
@@ -55,7 +82,7 @@ class AnimatedSprite
* duration of the specified time, 0 means default.
*/
void
- play(const std::string& action, int time = 0);
+ play(SpriteAction action, int time = 0);
/**
* Inform the animation of the passed time so that it can output the
@@ -86,7 +113,7 @@ class AnimatedSprite
* Sets the direction.
*/
void
- setDirection(const std::string& direction)
+ setDirection(SpriteDirection direction)
{
mDirection = direction;
}
@@ -97,17 +124,17 @@ class AnimatedSprite
* animations become a copy of those of the action "with".
*/
void
- substituteAction(const std::string& complete,
- const std::string& with);
+ substituteAction(SpriteAction complete,
+ SpriteAction with);
typedef std::map<std::string, Spriteset*> Spritesets;
typedef Spritesets::iterator SpritesetIterator;
Spritesets mSpritesets;
- typedef std::map<std::string, Action*> Actions;
+ typedef std::map<SpriteAction, Action*> Actions;
typedef Actions::iterator ActionIterator;
Actions mActions;
Action *mAction;
- std::string mDirection;
+ SpriteDirection mDirection;
int mLastTime;
float mSpeed;
@@ -126,6 +153,18 @@ class AnimatedSprite
*/
static std::string
getProperty(xmlNodePtr node, const char* name, const std::string& def);
+
+ /**
+ * converts a string into a SpriteAction enum
+ */
+ SpriteAction
+ makeSpriteAction(const std::string& action);
+
+ /**
+ * converts a string into a SpriteDirection enum
+ */
+ SpriteDirection
+ makeSpriteDirection(const std::string& direction);
};
#endif