aboutsummaryrefslogtreecommitdiffstats
path: root/src/animation.c
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-02-16 17:31:41 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-02-16 17:31:41 +0000
commit2a3b0c6057d913d931d5db361b004c89e78d0385 (patch)
tree89524e8030f126381b4346169919d7cda3287250 /src/animation.c
parent12b80da7f61df440a6e3252012436fb0baebe073 (diff)
downloadPenguinYippies-2a3b0c6057d913d931d5db361b004c89e78d0385.tar.gz
PenguinYippies-2a3b0c6057d913d931d5db361b004c89e78d0385.tar.bz2
PenguinYippies-2a3b0c6057d913d931d5db361b004c89e78d0385.zip
Animation working
Diffstat (limited to 'src/animation.c')
-rw-r--r--src/animation.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/animation.c b/src/animation.c
index deb764c..52210ae 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -29,7 +29,7 @@ Animation createAnimation(AnimationAsset* asset, double delay)
animation.height = asset->image.height;
animation.delay = delay;
- animation.lastTime = -1; // -1 for no last time.
+ animation.lastTime = -1.0; // -1.0 for no last time.
return animation;
}
@@ -44,14 +44,14 @@ void setAnimationFrame(Animation* animation, int frame)
animation->currentFrame = frame;
unsigned int nextFrameDataOffset = animation->width * animation->height * 4 * frame;
- UpdateTexture(animation->texture, ((unsigned int*)animation->asset->image.data) + nextFrameDataOffset);
+ UpdateTexture(animation->texture, ((unsigned char*)animation->asset->image.data) + nextFrameDataOffset);
}
void runAnimation(Animation* animation)
{
double currentTime = GetTime();
- if (animation->lastTime == -1 || currentTime - animation->lastTime >= animation->delay)
+ if (animation->lastTime == -1.0 || currentTime - animation->lastTime >= animation->delay)
{
// Count the frames up.
int newFrame = animation->currentFrame + 1;
@@ -67,3 +67,8 @@ void runAnimation(Animation* animation)
animation->lastTime = currentTime;
}
}
+
+void pauseAnimation(Animation* animation)
+{
+ animation->lastTime = -1.0;
+}