diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-07-29 14:39:37 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-07-29 14:39:37 +0000 |
commit | 314e38c7025a0654f221c7a0118dba203e59618e (patch) | |
tree | bb5b2ba81ac3cd12091870d5106df9f1dcc92363 /src/animation.cpp | |
parent | 43537eecfee22e8bf756e20c01a3363276d78b2c (diff) | |
download | mana-314e38c7025a0654f221c7a0118dba203e59618e.tar.gz mana-314e38c7025a0654f221c7a0118dba203e59618e.tar.bz2 mana-314e38c7025a0654f221c7a0118dba203e59618e.tar.xz mana-314e38c7025a0654f221c7a0118dba203e59618e.zip |
A bunch of cleanups.
Diffstat (limited to 'src/animation.cpp')
-rw-r--r-- | src/animation.cpp | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/animation.cpp b/src/animation.cpp index f9a5f6bb..cd716d78 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -59,25 +59,15 @@ Animation::update(unsigned int time) int Animation::getCurrentPhase() const { - if (mAnimationPhases.empty()) - { - return -1; - } - else - { - return iCurrentPhase->image; - } + return mAnimationPhases.empty() ? -1 : iCurrentPhase->image; } void Animation::addPhase(int image, unsigned int delay, int offsetX, int offsetY) { //add new phase to animation list - AnimationPhase newPhase; - newPhase.image = image; - newPhase.delay = delay; - newPhase.offsetX = offsetX; - newPhase.offsetY = offsetY; + AnimationPhase newPhase = { image, delay, offsetX, offsetY }; + mAnimationPhases.push_back(newPhase); //reset animation circle iCurrentPhase = mAnimationPhases.begin(); @@ -86,14 +76,15 @@ Animation::addPhase(int image, unsigned int delay, int offsetX, int offsetY) int Animation::getLength() { + if (mAnimationPhases.empty()) + return 0; + + std::list<AnimationPhase>::iterator i; int length = 0; - if (!mAnimationPhases.empty()) + for (i = mAnimationPhases.begin(); i != mAnimationPhases.end(); i++) { - for (i = mAnimationPhases.begin(); i != mAnimationPhases.end(); i++) - { - length += (*i).delay; - } + length += i->delay; } return length; } @@ -115,7 +106,6 @@ Action::~Action() Animation* Action::getAnimation(const std::string& direction) const { - Animation *animation = NULL; Animations::const_iterator i = mAnimations.find(direction); // When the direction isn't defined, try the default @@ -124,12 +114,7 @@ Action::getAnimation(const std::string& direction) const i = mAnimations.find("default"); } - if (i != mAnimations.end()) - { - animation = i->second; - } - - return animation; + return (i == mAnimations.end()) ? NULL : i->second; } void |