Terminate upon icecap formation

This commit is contained in:
Tangent 2024-01-12 23:30:18 -05:00
parent 1ba4397315
commit 1600a89643

View file

@ -115,6 +115,8 @@ export function IslandApplet() {
const basePos = len >> 1; const basePos = len >> 1;
const width = islands.width; const width = islands.width;
let timerId: number;
function drop(pos: number) { function drop(pos: number) {
const lowerNeighbors: number[] = []; const lowerNeighbors: number[] = [];
@ -149,7 +151,10 @@ export function IslandApplet() {
} }
// flat, increase elevation // flat, increase elevation
islands.data[pos]++; const newValue = ++islands.data[pos];
if (newValue == 9) {
clearInterval(timerId);
}
} }
function tick() { function tick() {
@ -167,7 +172,7 @@ export function IslandApplet() {
tick(); tick();
setInterval(tick, 1000 / 10); timerId = setInterval(tick, 1000 / 30);
return [canvas]; return [canvas];
} }