From 9b56235de8af601128783c7bc43635e3b0b0832c Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Sat, 13 Jan 2024 13:06:16 -0500 Subject: [PATCH] Adjust island location distribution --- island/grid.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/island/grid.ts b/island/grid.ts index d90e286..4a548db 100644 --- a/island/grid.ts +++ b/island/grid.ts @@ -1,4 +1,4 @@ -import { Prng, mulberry32 } from "../lib/prng"; +import { Prng, UINT_MAX, mulberry32 } from "../lib/prng"; import { BEACH, ICECAP } from "./data"; import { ALL_ISLANDS, @@ -28,15 +28,21 @@ export class IslandGrid { this.choose(ALL_ISLANDS), NO_ISLAND, NO_ISLAND, + NO_ISLAND, + NO_ISLAND, + NO_ISLAND, ]); const islandCount = islandBag.length; const spacing = (Math.PI * 2) / islandCount; + const rootX = width / 2; + const rootY = height / 2; + const xScale = width / 4; + const yScale = height / 4; for (let i = 0; i < islandCount; i++) { - const y = height / 2 + (Math.sin(spacing * i) * height) / 4; - const x = width / 2 + (Math.cos(spacing * i) * width) / 4; - - console.log("xy", x | 0, y | 0); + const rScale = this.rng() / UINT_MAX + 0.5; + const y = rootY + Math.sin(spacing * i) * yScale * rScale; + const x = rootX + Math.cos(spacing * i) * xScale * rScale; this.generators.push(islandBag[i](this, this.xy(x | 0, y | 0))); }