diff options
author | BoredGuy <osome3717@gmail.com> | 2025-08-21 20:07:04 +0300 |
---|---|---|
committer | BoredGuy <osome3717@gmail.com> | 2025-08-21 20:07:04 +0300 |
commit | 8a8ed6d3fa7059dbb2a95072bbae4bf4618349a0 (patch) | |
tree | 5f1383eb3983b2bfc73680322a4bf0b68abbf770 /include/game.h | |
parent | 251be1ac2d808dfd0fca5c0eb37398357ca7bb20 (diff) |
Work on animation subsystem
- Also incomplete refactor of inline functions
Diffstat (limited to 'include/game.h')
-rw-r--r-- | include/game.h | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/include/game.h b/include/game.h index e54afd3..530ae73 100644 --- a/include/game.h +++ b/include/game.h @@ -21,10 +21,25 @@ typedef enum DrawLayer { Foreground_Layer = 1 } DrawLayer; +typedef struct Animation { + int numFrames; + bool isLooping; + bool isComplete; + Rectangle srcRects[MAX_FRAMES]; + float frameTimes[MAX_FRAMES]; + + int currentFrame; + float currentFrameTimer; +} Animation; + typedef struct Sprite { Texture2D texture; DrawLayer layer; Rectangle destRect; //Destination rectangle relative to player position + + int numAnimations; //Zero for static spritesx + Animation animations[MAX_ANIMATIONS]; + int currentAnimation; } Sprite; typedef struct Entity { @@ -69,20 +84,8 @@ void InitGame(); void UpdateGame(float deltaTime); void DrawGame(); -static inline bool EntityAllocated(const Entity* e) { - return (e->flags & ENTITY_ALLOCATED); -} - -static inline bool SameEntity(const Entity* a, const Entity* b) { - return a->id == b->id; -} - -static inline void AddSpriteToEntity(Entity* e, Sprite s) { - if (e->numSprites < MAX_SPRITE_COUNT) { - e->sprites[e->numSprites++] = s; - } -} - +void UpdateCurrentSpriteAnimation(Sprite* sprite, float dt); +void DrawEntitySprite(const Sprite* sprite, int spriteIndex); #ifdef BEATEMUP_DEBUG void DebugHighlights(const Entity* e); |