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 --- assets/buttonBox.gif | Bin 0 -> 80166 bytes assets/button_box.gif | Bin 80166 -> 0 bytes assets/mainScreenBackground.png | Bin 0 -> 412228 bytes assets/penguinBackground.png | Bin 0 -> 29040 bytes assets/penguinLol.gif | Bin 0 -> 58532 bytes assets/penguin_lol.gif | Bin 58532 -> 0 bytes assets/toEmperorsEmporiumIcon.png | Bin 0 -> 933704 bytes assets/toGameIcon.png | Bin 0 -> 800908 bytes src/animation.c | 25 +++++++++++++++++++++++++ src/animation.h | 25 +++++++++++++++++++++++++ src/assets.c | 1 + src/assets.h | 10 ++++++++++ 12 files changed, 61 insertions(+) create mode 100644 assets/buttonBox.gif delete mode 100644 assets/button_box.gif create mode 100644 assets/mainScreenBackground.png create mode 100644 assets/penguinBackground.png create mode 100644 assets/penguinLol.gif delete mode 100644 assets/penguin_lol.gif create mode 100644 assets/toEmperorsEmporiumIcon.png create mode 100644 assets/toGameIcon.png create mode 100644 src/animation.c create mode 100644 src/animation.h create mode 100644 src/assets.c create mode 100644 src/assets.h diff --git a/assets/buttonBox.gif b/assets/buttonBox.gif new file mode 100644 index 0000000..495a785 Binary files /dev/null and b/assets/buttonBox.gif differ diff --git a/assets/button_box.gif b/assets/button_box.gif deleted file mode 100644 index 495a785..0000000 Binary files a/assets/button_box.gif and /dev/null differ diff --git a/assets/mainScreenBackground.png b/assets/mainScreenBackground.png new file mode 100644 index 0000000..13b0310 Binary files /dev/null and b/assets/mainScreenBackground.png differ diff --git a/assets/penguinBackground.png b/assets/penguinBackground.png new file mode 100644 index 0000000..5528250 Binary files /dev/null and b/assets/penguinBackground.png differ diff --git a/assets/penguinLol.gif b/assets/penguinLol.gif new file mode 100644 index 0000000..0e64e92 Binary files /dev/null and b/assets/penguinLol.gif differ diff --git a/assets/penguin_lol.gif b/assets/penguin_lol.gif deleted file mode 100644 index 0e64e92..0000000 Binary files a/assets/penguin_lol.gif and /dev/null differ diff --git a/assets/toEmperorsEmporiumIcon.png b/assets/toEmperorsEmporiumIcon.png new file mode 100644 index 0000000..beacd09 Binary files /dev/null and b/assets/toEmperorsEmporiumIcon.png differ diff --git a/assets/toGameIcon.png b/assets/toGameIcon.png new file mode 100644 index 0000000..a3f1eff Binary files /dev/null and b/assets/toGameIcon.png differ 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); +} diff --git a/src/animation.h b/src/animation.h new file mode 100644 index 0000000..8ec918f --- /dev/null +++ b/src/animation.h @@ -0,0 +1,25 @@ +#include "gameCommon.h" + +#define ANIMATION_DEFAULT_DELAY 0.1 + +#ifndef ANIMATION_H +#define ANIMATION_H + +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; + Texture texture; + + // Timing the frames. + double delay; + double lastTime; +} Animation; + +Animation loadAnimationFromFile(const char* fileName); +void freeAnimation(Animation* animation); + +#endif diff --git a/src/assets.c b/src/assets.c new file mode 100644 index 0000000..4ed3d53 --- /dev/null +++ b/src/assets.c @@ -0,0 +1 @@ +#include "assets.h" diff --git a/src/assets.h b/src/assets.h new file mode 100644 index 0000000..9846f3b --- /dev/null +++ b/src/assets.h @@ -0,0 +1,10 @@ +#include "gameCommon.h" + +#define ASSETS_NAME_MAX 100 +#define IMAGE_ASSET_COUNT 4 +#define ANIMATION_ASSET_COUNT 2 + +#ifndef ASSETS_H +#define ASSETS_H + +#endif -- cgit v1.2.3