Compare commits

...

3 Commits

Author SHA1 Message Date
HyperOnion 0f1b2f0d54 update readme. 2023-06-28 16:18:58 +02:00
HyperOnion 171d78adb0 clean up world constants to make more sense.
create a constant that represents the amount of tiles a box extends out
from its center in all 4 directions. compute the box size and box center
position constants from this new constant, instead of having them be
hard-coded.
2023-06-28 16:16:26 +02:00
HyperOnion 9193a43fbc 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.
2023-06-28 15:40:23 +02:00
3 changed files with 23 additions and 6 deletions

View File

@ -14,6 +14,7 @@ there's a demo video at `/assets/demo_video.webm`.
- QWEASD: paint with RGBYCM colors, respectively.
- ZX: paint with background colors.
- CV: paint with black and white.
- G: create grass.
- space: create box.
- backspace: delete/clear/empty tiles to your left and right, and where you're standing.

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);
});
}

View File

@ -1,7 +1,8 @@
import { iter_2d, range } from "./utils/range.mjs";
export const BOX_SIZE = 9;
export const CENTER = Math.floor(BOX_SIZE / 2);
const BOX_EXTENT_FROM_CENTER = 4;
export const BOX_SIZE = BOX_EXTENT_FROM_CENTER * 2 + 1;
export const CENTER = BOX_EXTENT_FROM_CENTER;