summaryrefslogtreecommitdiff
path: root/src/animation.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2006-09-20 23:34:11 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2006-09-20 23:34:11 +0000
commit073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79 (patch)
tree1838ff9e6a2c54519f2b61af8d54388f2feabfde /src/animation.cpp
parent0d2c09435711a5bcb4dfbd7d7900de6c415361ee (diff)
downloadmana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.tar.gz
mana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.tar.bz2
mana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.tar.xz
mana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.zip
tweaks at the animation system (mostly about fixing the looping attack animations of the monsters)
Diffstat (limited to 'src/animation.cpp')
-rw-r--r--src/animation.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/animation.cpp b/src/animation.cpp
index c1b27ebd..98a4abb8 100644
--- a/src/animation.cpp
+++ b/src/animation.cpp
@@ -39,45 +39,68 @@ Animation::reset()
iCurrentPhase = mAnimationPhases.begin();
}
-void
+
+bool
Animation::update(unsigned int time)
{
mTime += time;
if (mAnimationPhases.empty())
- return;
+ return true;
+ if (isTerminator(*iCurrentPhase))
+ return false;
unsigned int delay = iCurrentPhase->delay;
- if (!delay)
- return;
while (mTime > delay)
{
+ if (!delay)
+ return true;
mTime -= delay;
iCurrentPhase++;
if (iCurrentPhase == mAnimationPhases.end())
{
iCurrentPhase = mAnimationPhases.begin();
}
+ if (isTerminator(*iCurrentPhase))
+ return false;
+ delay = iCurrentPhase->delay;
}
+ return true;
}
+
int
Animation::getCurrentPhase() const
{
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 = { image, delay, offsetX, offsetY };
+ AnimationPhase newPhase = { image, delay, offsetX, offsetY};
mAnimationPhases.push_back(newPhase);
//reset animation circle
iCurrentPhase = mAnimationPhases.begin();
}
+void
+Animation::addTerminator()
+{
+ AnimationPhase terminator = { -1, 0, 0, 0};
+ mAnimationPhases.push_back(terminator);
+ iCurrentPhase = mAnimationPhases.begin();
+}
+
+bool
+Animation::isTerminator(AnimationPhase candidate)
+{
+ return (candidate.image < 0);
+}
+
int
Animation::getLength()
{