improve drawing of empty tiles.

make empty tiles render as 2x2 squares, fixing color alignment and chirality issues.

also make corners and centers of boxes be marked by empty tiles there
being darker than usual.
This commit is contained in:
HyperOnion 2023-06-28 15:40:23 +02:00
parent 7c7d939905
commit 9193a43fbc
1 changed files with 19 additions and 4 deletions

View File

@ -21,14 +21,29 @@ function checkerboard (x, y) {
return ((x ^ y) & 1) === 0;
}
function should_be_darker (x, y) {
const CENTER = world.CENTER;
const BOX_SIZE = world.BOX_SIZE;
return x === CENTER && y === CENTER
|| (x === 0 || x === BOX_SIZE - 1) && (y === 0 || y === BOX_SIZE - 1)
}
export function draw_floor (start_x, start_y, scale, invert = false) {
iter_2d(range(0, world.BOX_SIZE - 1), (x, y) => {
if (checkerboard(x, y) !== invert) {
graphics.set_color("#aaa");
} else {
graphics.set_color("#888");
let dark = "#888";
let bright = "#aaa";
if (should_be_darker(x, y)) {
dark = "#555";
bright = "#666";
}
graphics.set_color(dark);
draw_rect(x * scale + start_x, y * scale + start_y, scale);
graphics.set_color(bright);
draw_rect(x * scale + start_x, y * scale + start_y, scale / 2);
draw_rect((x + 0.5) * scale + start_x, (y + 0.5) * scale + start_y, scale / 2);
});
}