This commit is contained in:
33333-33333 2026-05-20 17:15:09 +09:00
commit e1bb10ff8a
12 changed files with 1336 additions and 526 deletions

26
grid.js Normal file
View file

@ -0,0 +1,26 @@
export const MAP_W = 172;
export const MAP_H = 122;
export const CELL_SIZE = 6;
export const SIZE = MAP_W * MAP_H;
export const INF = 1e9;
export function indexOf(x, y) {
return y * MAP_W + x;
}
export function xyOf(i) {
return [i % MAP_W, Math.floor(i / MAP_W)];
}
export function inside(x, y) {
return x >= 0 && y >= 0 && x < MAP_W && y < MAP_H;
}
export function clamp(v, a = 0, b = 1) {
return Math.max(a, Math.min(b, v));
}
export function nearMapEdge(x, y, margin = 1) {
return x < margin || y < margin || x >= MAP_W - margin || y >= MAP_H - margin;
}