tick-based iteration
This commit is contained in:
parent
6bf157bd32
commit
5e87ba9380
1 changed files with 12 additions and 7 deletions
19
island.ts
19
island.ts
|
@ -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);
|
||||
islands
|
||||
.floodSearch(islands.xy(x, y), (tile) => tile > 0)
|
||||
.forEach((pos) => islands.data[pos]++);
|
||||
function tick() {
|
||||
const pos = islands.rng() % islands.data.length;
|
||||
|
||||
renderIslands(islands, cx);
|
||||
islands
|
||||
.floodSearch(pos, (tile) => tile > 0)
|
||||
.forEach((pos) => islands.data[pos]++);
|
||||
|
||||
renderIslands(islands, cx);
|
||||
}
|
||||
|
||||
tick();
|
||||
|
||||
setInterval(tick, 1000 / 10);
|
||||
|
||||
return [canvas];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue