Update render order of bricks when grabbing
This commit is contained in:
+11
-8
@@ -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
|
// Check if player has won
|
||||||
var has_won = true;
|
var has_won = true;
|
||||||
for (state.board.tiles) |board_row| {
|
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);
|
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;
|
has_won = has_won and valid;
|
||||||
}
|
}
|
||||||
@@ -915,14 +925,7 @@ pub fn updateAndRender(memory: *platform.AppMemory, buffer: platform.OffscreenBu
|
|||||||
if (tile > 0) {
|
if (tile > 0) {
|
||||||
const pos = getTilePos(i, j).add(brick.pos);
|
const pos = getTilePos(i, j).add(brick.pos);
|
||||||
const camera_pos = pos.add(state.camera.pos);
|
const camera_pos = pos.add(state.camera.pos);
|
||||||
var color: u32 = if (brick.rotating) 0xFF007800 else brick.color;
|
const 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fillSquare(
|
fillSquare(
|
||||||
buffer,
|
buffer,
|
||||||
|
|||||||
Reference in New Issue
Block a user