tick-based iteration

This commit is contained in:
Tangent Wantwight 2024-01-12 22:31:48 -05:00
parent 6bf157bd32
commit 5e87ba9380

View file

@ -103,15 +103,20 @@ export function IslandApplet() {
cx.scale(BLOWUP, BLOWUP);
const islands = new IslandGrid(WIDTH, HEIGHT, 128);
const x = islands.rng();
const y = islands.rng();
islands.set(x, y, 1);
function tick() {
const pos = islands.rng() % islands.data.length;
islands
.floodSearch(islands.xy(x, y), (tile) => tile > 0)
.floodSearch(pos, (tile) => tile > 0)
.forEach((pos) => islands.data[pos]++);
renderIslands(islands, cx);
}
tick();
setInterval(tick, 1000 / 10);
return [canvas];
}