diff options
| author | Leander Scherer <leander@schererleander.de> | 2026-03-11 23:16:49 +0100 |
|---|---|---|
| committer | Leander Scherer <leander@schererleander.de> | 2026-03-11 23:16:49 +0100 |
| commit | d3a1bb552e9efc4e516841158aaaea3d8ab9202d (patch) | |
| tree | 16957aab86a6fdfd6c6aae0873babe359bf386a9 /include/entities.h | |
| parent | 9fb384552cb0a036a5978dfc40cddbbe2d29727c (diff) | |
refactor(entity): replace EntityManager with typed Entities struct
Diffstat (limited to 'include/entities.h')
| -rw-r--r-- | include/entities.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/include/entities.h b/include/entities.h new file mode 100644 index 0000000..7bd38f3 --- /dev/null +++ b/include/entities.h @@ -0,0 +1,126 @@ +#pragma once + +#include "raylib.h" +#include "raytmx.h" + +#include "map.h" +#include "player.h" + +#define MAX_ENTITIES 120 + +typedef enum { + PICKUP_COIN, + PICKUP_POTION, + PICKUP_BOMB, + PICKUP_FULL_HEART, + PICKUP_HALF_HEART, + PICKUP_GOLD_BAR, + PICKUP_GOLD_NUGGET +} PickupType; + +static const int PICKUP_TILE_ID[] = {0, 4, 8, 12, 16, 20, 24}; + +typedef enum { STATE_IDLE, STATE_PATROL, STATE_CHASE, STATE_ATTACK } EnemyState; + +typedef struct { + PickupType type; + Vector2 position; + Rectangle bounds; + int value; + bool active; + uint32_t gid; +} Pickup; + +typedef struct { + Vector2 position; + Rectangle bounds; + int uniqueId; + bool active; + uint32_t gid; +} Key; + +typedef struct { + Vector2 position; + Rectangle bounds; + int health; + EnemyState state; + + TmxTileset tileset; + int currentFrame; + float frameTime; + bool facingRight; + + bool active; +} Bat; + +typedef struct { + Vector2 position; + Rectangle bounds; + int health; + EnemyState state; + + TmxTileset tileset; + int currentFrame; + float frameTime; + bool facingRight; + + bool active; +} Slime; + +typedef struct { + Vector2 position; + Rectangle bounds; + int health; + EnemyState state; + + TmxTileset tileset; + int currentFrame; + float frameTime; + bool facingRight; + + bool active; +} FlyingSkull; + +typedef struct { + Vector2 position; + Rectangle bounds; + bool active; +} Vase; + +typedef struct { + Vector2 position; + Rectangle bounds; + bool active; +} Crate; + +struct Entities { + Pickup pickups[MAX_ENTITIES]; + int pickupsCount; + + Key keys[MAX_ENTITIES]; + int keysCount; + + Bat bats[MAX_ENTITIES]; + int batsCount; + + Slime slimes[MAX_ENTITIES]; + int slimesCount; + + FlyingSkull flyingSkulls[MAX_ENTITIES]; + int flyingSkullsCount; + + Vase vases[MAX_ENTITIES]; + int vasesCount; + + Crate crates[MAX_ENTITIES]; + int cratesCount; +}; + +void UpdateBat(Bat *bat, Player *player, Map *map); +void DrawBat(Bat *bat); + +void UpdateSlime(Slime *slime, Player *player, Map *map); +void DrawSlime(Slime *slime); + +void UpdateFlyingSkull(FlyingSkull *skull, Player *player, Map *map); +void DrawFlyingSkull(FlyingSkull *skull); |
