refactor
This commit is contained in:
parent
a0650ee706
commit
cc2ae41bb5
1 changed files with 9 additions and 3 deletions
12
island.ts
12
island.ts
|
@ -157,13 +157,19 @@ export function IslandApplet() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dropWithin(tiles: number[]) {
|
||||||
|
if (tiles.length > 0) {
|
||||||
|
drop(tiles[islands.rng() % tiles.length]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function tick() {
|
function tick() {
|
||||||
const islandTiles = islands.floodSearch(basePos, (tile) => tile > 0);
|
const islandTiles = islands.floodSearch(basePos, (tile) => tile > 0);
|
||||||
drop(islandTiles[islands.rng() % islandTiles.length]);
|
dropWithin(islandTiles);
|
||||||
drop(islandTiles[islands.rng() % islandTiles.length]);
|
dropWithin(islandTiles);
|
||||||
|
|
||||||
const mountainTiles = islands.floodSearch(basePos - 8, (tile) => tile > 4);
|
const mountainTiles = islands.floodSearch(basePos - 8, (tile) => tile > 4);
|
||||||
drop(mountainTiles[islands.rng() % mountainTiles.length]);
|
dropWithin(mountainTiles);
|
||||||
|
|
||||||
// const erodePos = islandTiles[islands.rng() % islandTiles.length];
|
// const erodePos = islandTiles[islands.rng() % islandTiles.length];
|
||||||
// islands.data[erodePos] = Math.max(islands.data[erodePos] - 1, 0);
|
// islands.data[erodePos] = Math.max(islands.data[erodePos] - 1, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue