From 125be3c1880d9f64580bf9c753dd85c5cbc1cfc4 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 3 Aug 2024 16:37:48 +1000 Subject: Add helpers for getting map tiles --- map.c | 8 ++++++++ map.h | 2 ++ render.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/map.c b/map.c index 3313f10..5dbe236 100644 --- a/map.c +++ b/map.c @@ -3,3 +3,11 @@ int map_size(int w, int h) { return sizeof(Map) + w * h * sizeof(Map_Tile); } + +Map_Tile* map_tiles(Map* m) { + return (Map_Tile*)&m[1]; +} + +const Map_Tile* map_tilesc(const Map* m) { + return (Map_Tile*)&m[1]; +} diff --git a/map.h b/map.h index fbd64f1..9e2a413 100644 --- a/map.h +++ b/map.h @@ -8,5 +8,7 @@ typedef struct Map { typedef unsigned Map_Tile; int map_size(int w, int h); +Map_Tile* map_tiles(Map* m); +const Map_Tile* map_tilesc(const Map* m); #endif diff --git a/render.c b/render.c index 32ca500..13eb99e 100644 --- a/render.c +++ b/render.c @@ -758,7 +758,7 @@ void ren_map( const int* left ) { int x, y, w, h, hh, hhi, ey; - const int* data = (const int*)&map[1]; + const Map_Tile* data = map_tilesc(map); /* temp */ const Texture* texture = get_texture(asset_id_brick_texture); const Texture* ceiling = get_texture(asset_id_floorboardsbot_texture); -- cgit v1.2.3-54-g00ecf