From 64bb931e18825b285dd93d0b9987ef72ece15ab4 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Wed, 14 Feb 2024 17:06:35 -0700 Subject: Working on animation stuff --- src/animation.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/animation.c (limited to 'src/animation.c') diff --git a/src/animation.c b/src/animation.c new file mode 100644 index 0000000..f173401 --- /dev/null +++ b/src/animation.c @@ -0,0 +1,25 @@ +#include "animation.h" +#include "game.h" +#include + +Animation loadAnimationFromFile(const char* fileName) +{ + Animation animation; + + // Load image in. + animation.image = LoadImageAnim(fileName, &animation.frameCount); + animation.texture = LoadTextureFromImage(animation.image); + + // Set options. + animation.currentFrame = 0; + animation.delay = ANIMATION_DEFAULT_DELAY; + animation.lastTime = -1.0; // -1.0 means there wasn't a last time. + + return animation; +} + +void freeAnimation(Animation* animation) +{ + UnloadImage(animation->image); + UnloadTexture(animation->texture); +} -- cgit v1.2.3