add diagonals to "downhill" check
This commit is contained in:
parent
304134d15a
commit
3019a8b713
21
island.ts
21
island.ts
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue