aboutsummaryrefslogtreecommitdiffstats
path: root/src/animation.c
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 18:50:36 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 18:50:36 +0000
commitc11c0383fc4609dd67012d9e3aa44b7fa58c999c (patch)
tree6152ba5d513b98b617d85b01d44068b8abf1d1ab /src/animation.c
parent2416dc256e53c431c5226827d90cf504f190f9ec (diff)
downloadPenguinYippies-c11c0383fc4609dd67012d9e3aa44b7fa58c999c.tar.gz
PenguinYippies-c11c0383fc4609dd67012d9e3aa44b7fa58c999c.tar.bz2
PenguinYippies-c11c0383fc4609dd67012d9e3aa44b7fa58c999c.zip
Better animation and clicky stuff
Diffstat (limited to 'src/animation.c')
-rw-r--r--src/animation.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/animation.c b/src/animation.c
index 1a2f612..95447b2 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -28,6 +28,7 @@ Animation createAnimation(AnimationAsset* asset, double delay)
animation.width = asset->image.width;
animation.height = asset->image.height;
+ animation.repeat = true;
animation.delay = delay;
animation.lastTime = -1.0; // -1.0 for no last time.
@@ -65,7 +66,14 @@ void runAnimation(Animation* animation)
if (newFrame >= animation->frameCount)
{
- newFrame = 0;
+ if (animation->repeat)
+ {
+ newFrame = 0;
+ }
+ else
+ {
+ newFrame = animation->frameCount - 1;
+ }
}
// Set the frame
@@ -81,6 +89,13 @@ void playAnimation(Animation* animation)
animation->lastTime = -1.0;
}
+void replayAnimation(Animation* animation)
+{
+ animation->playing = true;
+ animation->lastTime = -1.0;
+ setAnimationFrame(animation, 0);
+}
+
void pauseAnimation(Animation* animation)
{
animation->playing = false;