diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-16 17:38:55 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-16 17:38:55 +0000 |
commit | 3631e9c1888d2d2e43e85af654fc0544594795f2 (patch) | |
tree | b74484a01b59971c0c60a96ac637ca3113e50e4c /src/animation.c | |
parent | 2a3b0c6057d913d931d5db361b004c89e78d0385 (diff) | |
download | PenguinYippies-3631e9c1888d2d2e43e85af654fc0544594795f2.tar.gz PenguinYippies-3631e9c1888d2d2e43e85af654fc0544594795f2.tar.bz2 PenguinYippies-3631e9c1888d2d2e43e85af654fc0544594795f2.zip |
Animation play and pause working
Diffstat (limited to 'src/animation.c')
-rw-r--r-- | src/animation.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/animation.c b/src/animation.c index 52210ae..1a2f612 100644 --- a/src/animation.c +++ b/src/animation.c @@ -31,6 +31,8 @@ Animation createAnimation(AnimationAsset* asset, double delay) animation.delay = delay; animation.lastTime = -1.0; // -1.0 for no last time. + animation.playing = false; + return animation; } @@ -49,6 +51,11 @@ void setAnimationFrame(Animation* animation, int frame) void runAnimation(Animation* animation) { + if (!animation->playing) + { + return; + } + double currentTime = GetTime(); if (animation->lastTime == -1.0 || currentTime - animation->lastTime >= animation->delay) @@ -68,7 +75,19 @@ void runAnimation(Animation* animation) } } +void playAnimation(Animation* animation) +{ + animation->playing = true; + animation->lastTime = -1.0; +} + void pauseAnimation(Animation* animation) { + animation->playing = false; +} + +void toggleAnimation(Animation* animation) +{ + animation->playing = !animation->playing; animation->lastTime = -1.0; } |