From d239d818eb65d6c066b5e3601514770e51593187 Mon Sep 17 00:00:00 2001 From: Simen Kirkvik Date: Sun, 15 Mar 2026 15:20:55 +0100 Subject: [PATCH] Update render order of bricks when grabbing --- src/root.zig | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/root.zig b/src/root.zig index 107eca3..f555d3a 100644 --- a/src/root.zig +++ b/src/root.zig @@ -817,6 +817,15 @@ pub fn updateAndRender(memory: *platform.AppMemory, buffer: platform.OffscreenBu } } + // NOTE: Move the grabbed brick to the end of the array. This makes become + // the last to be rendered, and then appear above all the other bricks. + if (state.grabbed_brick_index) |i| { + const tmp = state.bricks[state.bricks.len - 1]; + state.bricks[state.bricks.len - 1] = state.bricks[i]; + state.bricks[i] = tmp; + state.grabbed_brick_index = state.bricks.len - 1; + } + // Check if player has won var has_won = true; for (state.board.tiles) |board_row| { @@ -832,6 +841,7 @@ pub fn updateAndRender(memory: *platform.AppMemory, buffer: platform.OffscreenBu }, } }; + // xor bby const valid = (board_tile.taken and !is_day_or_month) or (!board_tile.taken and is_day_or_month); has_won = has_won and valid; } @@ -915,14 +925,7 @@ pub fn updateAndRender(memory: *platform.AppMemory, buffer: platform.OffscreenBu if (tile > 0) { const pos = getTilePos(i, j).add(brick.pos); const camera_pos = pos.add(state.camera.pos); - var color: u32 = if (brick.rotating) 0xFF007800 else brick.color; - - if (comptime builtin.mode == std.builtin.OptimizeMode.Debug) { - const board_index = brick.board_indices[i][j]; - if (board_index != null) { - color = 0xFFFF0000; - } - } + const color: u32 = if (brick.rotating) 0xFF007800 else brick.color; fillSquare( buffer,