From c8fdef3b8f9b2eaab5fdccc9f8a9888d12972cc5 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 4 Sep 2025 19:19:47 -0700 Subject: Fix the checkerboard demo, which was being rendered as an orthogonal map after the recent changes. --- demos/checkerboard/checkerboard.c | 3 ++- include/isogfx/gfx2d.h | 16 +++++++++++----- src/gfx2d.c | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/demos/checkerboard/checkerboard.c b/demos/checkerboard/checkerboard.c index 467da61..243f7a8 100644 --- a/demos/checkerboard/checkerboard.c +++ b/demos/checkerboard/checkerboard.c @@ -86,7 +86,8 @@ static bool init(GfxApp* app, GfxAppState* state, int argc, const char** argv) { .tile_height = TILE_HEIGHT, .world_width = WORLD_WIDTH, .world_height = WORLD_HEIGHT, - .num_tiles = NUM_TILES}); + .num_tiles = NUM_TILES, + .orientation = MapIsometric}); const Tile black = gfx2d_make_tile(iso, &tile_set[Black]); const Tile white = gfx2d_make_tile(iso, &tile_set[White]); diff --git a/include/isogfx/gfx2d.h b/include/isogfx/gfx2d.h index 59566f3..a3ddbb6 100644 --- a/include/isogfx/gfx2d.h +++ b/include/isogfx/gfx2d.h @@ -37,12 +37,18 @@ typedef struct TileDesc { }; } TileDesc; +typedef enum MapOrientation { + MapOrthogonal, + MapIsometric, +} MapOrientation; + typedef struct MapDesc { - int tile_width; // Base tile width in pixels. - int tile_height; // Base tile height in pixels. - int world_width; // World width in tiles. - int world_height; // World height in tiles. - int num_tiles; // Number of tiles to allocate memory for. + int tile_width; // Base tile width in pixels. + int tile_height; // Base tile height in pixels. + int world_width; // World width in tiles. + int world_height; // World height in tiles. + int num_tiles; // Number of tiles to allocate memory for. + MapOrientation orientation; // Map orientation. } MapDesc; typedef struct IsoGfxDesc { diff --git a/src/gfx2d.c b/src/gfx2d.c index 266a5f7..f609c98 100644 --- a/src/gfx2d.c +++ b/src/gfx2d.c @@ -263,6 +263,8 @@ void gfx2d_make_map(Gfx2d* gfx, const MapDesc* desc) { .base_tile_width = desc->tile_width, .base_tile_height = desc->tile_height, .num_layers = 1, + .flags = + (desc->orientation == MapOrthogonal) ? Tm_Orthogonal : Tm_Isometric, }; gfx->tileset = memstack_alloc_aligned(&gfx->stack, tileset_size_bytes, 4); -- cgit v1.2.3