diff options
author | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-15 23:32:41 +0000 |
---|---|---|
committer | nathansmith117 <thenathansmithsmith@gmail.com> | 2024-02-15 23:32:41 +0000 |
commit | 12b80da7f61df440a6e3252012436fb0baebe073 (patch) | |
tree | 9bae4b3df40534df2c015754d6fb9ed75e03f87f /src/animation.h | |
parent | e05dbe42fd8ffc6601887d19afcba545a6401733 (diff) | |
download | PenguinYippies-12b80da7f61df440a6e3252012436fb0baebe073.tar.gz PenguinYippies-12b80da7f61df440a6e3252012436fb0baebe073.tar.bz2 PenguinYippies-12b80da7f61df440a6e3252012436fb0baebe073.zip |
Fixed up animation system
Diffstat (limited to 'src/animation.h')
-rw-r--r-- | src/animation.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/animation.h b/src/animation.h index 089e6e1..963af74 100644 --- a/src/animation.h +++ b/src/animation.h @@ -1,30 +1,44 @@ #include "gameCommon.h" +#include <raylib.h> #define ANIMATION_DEFAULT_DELAY 0.1 #ifndef ANIMATION_H #define ANIMATION_H +// The asset is what is loaded from a file and the animation is like a instance of it. + +typedef struct AnimationAsset { + // The animation is stored in a image and the texture is used for fast rendering. + int frameCount; + Image image; +} AnimationAsset; + typedef struct Animation { // Frame stuff. int frameCount; int currentFrame; - // The animation is stored in a image and the texture is used for fast rendering. - Image image; + AnimationAsset* asset; Texture texture; + int width; + int height; + // Timing the frames. double delay; double lastTime; } Animation; -Animation loadAnimationFromFile(const char* fileName); -void freeAnimation(Animation* animation); +AnimationAsset loadAnimationAssetFromFile(const char* fileName); +void freeAnimationAsset(AnimationAsset* animationAsset); + +Animation createAnimation(AnimationAsset* asset, double delay); +void closeAnimation(Animation* animation); // Set the frame and update the texture. -void setAnimationFrame(Animation * animation, int frame); +void setAnimationFrame(Animation* animation, int frame); -void runAnimation(Animation * animation); +void runAnimation(Animation* animation); #endif |