From fe121a40abeb44990a0a693d897d250b0e8038ba Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Sat, 13 Jan 2024 00:19:34 -0500 Subject: [PATCH] random lobes --- island.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/island.ts b/island.ts index 9578358..8759c69 100644 --- a/island.ts +++ b/island.ts @@ -113,6 +113,14 @@ export function IslandApplet() { const len = islands.data.length; const basePos = len >> 1; + const lobePos1 = islands.xy( + (WIDTH >> 1) + (islands.rng() % 48) - 24, + (HEIGHT >> 1) + (islands.rng() % 48) - 24 + ); + const lobePos2 = islands.xy( + (WIDTH >> 1) + (islands.rng() % 48) - 24, + (HEIGHT >> 1) + (islands.rng() % 48) - 24 + ); const width = islands.width; let timerId: number; @@ -164,25 +172,27 @@ export function IslandApplet() { } function tick() { - const lowlandTiles = islands.floodSearch(basePos + 12, (tile) => tile > 0); + const lowlandTiles1 = islands.floodSearch(lobePos1, (tile) => tile > 0); + const lowlandTiles2 = islands.floodSearch(lobePos2, (tile) => tile > 0); // grow shore - const shoreTiles = lowlandTiles.filter((pos) => islands.data[pos] == 0); - dropWithin(shoreTiles); - dropWithin(shoreTiles); + const shoreTiles1 = lowlandTiles1.filter((pos) => islands.data[pos] == 0); + dropWithin(shoreTiles1); + const shoreTiles2 = lowlandTiles2.filter((pos) => islands.data[pos] == 0); + dropWithin(shoreTiles2); // seed beach - const beachTiles = lowlandTiles.filter((pos) => islands.data[pos] == 1); + const beachTiles = lowlandTiles1.filter((pos) => islands.data[pos] == 1); dropWithin(beachTiles); // expand forest - const forestTiles = lowlandTiles.filter((pos) => islands.data[pos] == 2); + const forestTiles = lowlandTiles1.filter((pos) => islands.data[pos] == 2); dropWithin(forestTiles); dropWithin(forestTiles); dropWithin(forestTiles); // form mountain - const mountainTiles = islands.floodSearch(basePos - 12, (tile) => tile > 4); + const mountainTiles = islands.floodSearch(basePos, (tile) => tile > 4); dropWithin(mountainTiles); // const erodePos = islandTiles[islands.rng() % islandTiles.length];