From 2c5e621cdaef674fb6c812d8937598575784db63 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 6 Sep 2025 18:21:43 -0700 Subject: Add preliminary support for multiple layers in ortho maps --- src/gfx2d.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gfx2d.c b/src/gfx2d.c index e79dd3e..14e0539 100644 --- a/src/gfx2d.c +++ b/src/gfx2d.c @@ -651,18 +651,19 @@ static void draw_map_ortho(Gfx2d* gfx) { assert(gfx); assert(gfx->map); - // TODO: Handle multiple layers. - const Tm_Layer* layer = tm_map_get_layer(gfx->map, 0); - - // TODO: This currently renders with tile granularity. Do so instead in terms - // of pixels for more accurate camera panning. The camera coordinates are - // already given in pixels. - for (int wy = gfx->camera.y / gfx->map->base_tile_height; - wy < gfx->map->world_height; ++wy) { - for (int wx = gfx->camera.x / gfx->map->base_tile_width; - wx < gfx->map->world_width; ++wx) { - const Tile tile = tm_layer_get_tile(gfx->map, layer, wx, wy); - draw_tile_ortho(gfx, tile, wx, wy); + for (uint16_t l = 0; l < gfx->map->num_layers; ++l) { + const Tm_Layer* layer = tm_map_get_layer(gfx->map, l); + + // TODO: This currently renders with tile granularity. Do so instead in + // terms of pixels for more accurate camera panning. The camera coordinates + // are already given in pixels. + for (int wy = gfx->camera.y / gfx->map->base_tile_height; + wy < gfx->map->world_height; ++wy) { + for (int wx = gfx->camera.x / gfx->map->base_tile_width; + wx < gfx->map->world_width; ++wx) { + const Tile tile = tm_layer_get_tile(gfx->map, layer, wx, wy); + draw_tile_ortho(gfx, tile, wx, wy); + } } } } -- cgit v1.2.3