add diagonals to "downhill" check

This commit is contained in:
Tangent Wantwight 2024-01-12 23:25:09 -05:00
parent 304134d15a
commit 3019a8b713
1 changed files with 18 additions and 3 deletions

View File

@ -124,6 +124,8 @@ export function IslandApplet() {
}
}
// try to roll in cardinal directions
check((pos - width) % len);
check((pos - 1) % len);
check((pos + 1) % len);
@ -131,10 +133,23 @@ export function IslandApplet() {
if (lowerNeighbors.length > 0) {
const downhill = lowerNeighbors[islands.rng() % lowerNeighbors.length];
drop(downhill);
} else {
islands.data[pos]++;
return drop(downhill);
}
// try to roll in diagonal directions
check((pos - width - 1) % len);
check((pos - width + 1) % len);
check((pos + width - 1) % len);
check((pos + width + 1) % len);
if (lowerNeighbors.length > 0) {
const downhill = lowerNeighbors[islands.rng() % lowerNeighbors.length];
return drop(downhill);
}
// flat, increase elevation
islands.data[pos]++;
}
function tick() {