random lobes
This commit is contained in:
parent
46827f3428
commit
fe121a40ab
1 changed files with 17 additions and 7 deletions
24
island.ts
24
island.ts
|
@ -113,6 +113,14 @@ export function IslandApplet() {
|
||||||
|
|
||||||
const len = islands.data.length;
|
const len = islands.data.length;
|
||||||
const basePos = len >> 1;
|
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;
|
const width = islands.width;
|
||||||
|
|
||||||
let timerId: number;
|
let timerId: number;
|
||||||
|
@ -164,25 +172,27 @@ export function IslandApplet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tick() {
|
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
|
// grow shore
|
||||||
const shoreTiles = lowlandTiles.filter((pos) => islands.data[pos] == 0);
|
const shoreTiles1 = lowlandTiles1.filter((pos) => islands.data[pos] == 0);
|
||||||
dropWithin(shoreTiles);
|
dropWithin(shoreTiles1);
|
||||||
dropWithin(shoreTiles);
|
const shoreTiles2 = lowlandTiles2.filter((pos) => islands.data[pos] == 0);
|
||||||
|
dropWithin(shoreTiles2);
|
||||||
|
|
||||||
// seed beach
|
// seed beach
|
||||||
const beachTiles = lowlandTiles.filter((pos) => islands.data[pos] == 1);
|
const beachTiles = lowlandTiles1.filter((pos) => islands.data[pos] == 1);
|
||||||
dropWithin(beachTiles);
|
dropWithin(beachTiles);
|
||||||
|
|
||||||
// expand forest
|
// 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);
|
dropWithin(forestTiles);
|
||||||
dropWithin(forestTiles);
|
dropWithin(forestTiles);
|
||||||
|
|
||||||
// form mountain
|
// form mountain
|
||||||
const mountainTiles = islands.floodSearch(basePos - 12, (tile) => tile > 4);
|
const mountainTiles = islands.floodSearch(basePos, (tile) => tile > 4);
|
||||||
dropWithin(mountainTiles);
|
dropWithin(mountainTiles);
|
||||||
|
|
||||||
// const erodePos = islandTiles[islands.rng() % islandTiles.length];
|
// const erodePos = islandTiles[islands.rng() % islandTiles.length];
|
||||||
|
|
Loading…
Add table
Reference in a new issue