track nesting depth in boxes.

This commit is contained in:
HyperOnion 2023-06-24 18:51:42 +02:00
parent 5643fd86e2
commit 1c79bca1c9
1 changed files with 2 additions and 0 deletions

View File

@ -8,6 +8,7 @@ export const CENTER = Math.floor(BOX_SIZE / 2);
function create_world (size) {
return {
tiles: Array(size).fill(0).map(_ => Array(size).fill(0)),
depth: 0,
};
}
const world = create_world(BOX_SIZE);
@ -29,6 +30,7 @@ export function get_tile (world, x, y) {
export function create_box (parent) {
return {
...create_world(BOX_SIZE),
depth: parent.depth + 1,
parent,
};
}