From 9193a43fbcab0cc7dc581702c83cc0798c1c4db8 Mon Sep 17 00:00:00 2001 From: HyperOnion <> Date: Wed, 28 Jun 2023 15:40:23 +0200 Subject: [PATCH] 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. --- js/graphics.mjs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/js/graphics.mjs b/js/graphics.mjs index ccfc739..38007f8 100644 --- a/js/graphics.mjs +++ b/js/graphics.mjs @@ -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); }); }