2023-06-23 09:37:25 +00:00
|
|
|
export const BOX_SIZE = 9;
|
2023-06-23 10:05:40 +00:00
|
|
|
export const CENTER = Math.floor(BOX_SIZE / 2);
|
2023-06-23 09:37:25 +00:00
|
|
|
|
|
|
|
|
2023-06-23 10:05:40 +00:00
|
|
|
|
|
|
|
function create_world (size) {
|
|
|
|
return Array(BOX_SIZE).fill(0).map(_ => Array(BOX_SIZE).fill(0));
|
|
|
|
}
|
|
|
|
const world = create_world(BOX_SIZE);
|
|
|
|
const parent_stack = [];
|
|
|
|
let current_world = world;
|
2023-06-23 09:37:25 +00:00
|
|
|
|
|
|
|
export function set_tile (x, y, tile) {
|
2023-06-23 10:05:40 +00:00
|
|
|
current_world[x][y] = tile;
|
2023-06-23 09:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function get_tile (x, y) {
|
2023-06-23 10:05:40 +00:00
|
|
|
return current_world[x][y];
|
|
|
|
}
|
|
|
|
|
|
|
|
export function create_box () {
|
|
|
|
return create_world(BOX_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function enter_box (box) {
|
|
|
|
parent_stack.push(current_world);
|
|
|
|
current_world = box;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function exit_box () {
|
|
|
|
if (parent_stack.length > 0) {
|
|
|
|
current_world = parent_stack.pop();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2023-06-23 09:37:25 +00:00
|
|
|
}
|