diff options
| author | Leander Scherer <leander@schererleander.de> | 2026-03-12 01:35:15 +0100 |
|---|---|---|
| committer | Leander Scherer <leander@schererleander.de> | 2026-03-12 01:35:15 +0100 |
| commit | aafdfa0734b7c5dcea9f0e914ef6c66852b9d3a7 (patch) | |
| tree | 8e20b2282b445d70d4069ecf5a62aaa02c5b0f29 | |
| parent | ae6ac413632b427e31a26020a94864669af1ba10 (diff) | |
chore: use globals
| -rw-r--r-- | include/entities.h | 2 | ||||
| -rw-r--r-- | include/globals.h | 4 | ||||
| -rw-r--r-- | include/player.h | 2 | ||||
| -rw-r--r-- | src/main.c | 21 |
4 files changed, 12 insertions, 17 deletions
diff --git a/include/entities.h b/include/entities.h index 7bd38f3..b98b853 100644 --- a/include/entities.h +++ b/include/entities.h @@ -34,7 +34,7 @@ typedef struct { typedef struct { Vector2 position; Rectangle bounds; - int uniqueId; + char* uniqueId; bool active; uint32_t gid; } Key; diff --git a/include/globals.h b/include/globals.h new file mode 100644 index 0000000..bcb7d57 --- /dev/null +++ b/include/globals.h @@ -0,0 +1,4 @@ +#define SCREEN_HEIGHT 1080 +#define SCREEN_WIDTH 1920 +#define TARGET_FPS 280 +#define GAME_NAME "Dungeons" diff --git a/include/player.h b/include/player.h index 99a3ce9..b26bc20 100644 --- a/include/player.h +++ b/include/player.h @@ -5,7 +5,7 @@ #include "map.h" -typedef enum { PLAYER_IDLE, PLAYER_WALK, PLAYER_ATTACK } PlayerState; +typedef enum { PLAYER_IDLE, PLAYER_WALK, PLAYER_ATTACK, PLAYER_DIE, PLAYER_FALL } PlayerState; typedef struct { int potions; @@ -2,36 +2,27 @@ #define RAYTMX_IMPLEMENTATION #include "raytmx.h" +#include "globals.h" #include "entities.h" #include "fairy.h" #include "map.h" #include "player.h" -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 -#define TARGET_FPS 60 int main(void) { - InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Dungeon"); + InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, GAME_NAME); SetTargetFPS(TARGET_FPS); Entities entities = {0}; Map *map = LoadMap("assets/maps/debug.tmx", &entities); - TraceLog(LOG_INFO, "Entities loaded:"); - TraceLog(LOG_INFO, "pickups: %d", entities.pickupsCount); - TraceLog(LOG_INFO, "keys: %d", entities.keysCount); - TraceLog(LOG_INFO, "bats: %d", entities.batsCount); - TraceLog(LOG_INFO, "slimes: %d", entities.slimesCount); - TraceLog(LOG_INFO, "flying skulls: %d", entities.flyingSkullsCount); - TraceLog(LOG_INFO, "vases: %d", entities.vasesCount); - TraceLog(LOG_INFO, "crates: %d", entities.cratesCount); + Marker *spawn = FindMarker(map, "player_spawn"); + Vector2 spawnPos = spawn ? spawn->position : (Vector2){0, 0}; RaytmxExternalTileset playerTileset = LoadTSX("assets/tilesets/elf.tsx"); - - Player player = {.position = {192.0f, 192.0f}, + Player player = {.position = spawnPos, .speed = 80.0f, - .bounds = {185.0f, 184.0f, 13.0f, 16.0f}, + .bounds = {player.position.x, player.position.y, playerTileset.tileset.tileWidth - 4, playerTileset.tileset.tileHeight}, .state = PLAYER_IDLE, .facingRight = true, .tileset = playerTileset.tileset, |
