Adjust island location distribution
This commit is contained in:
parent
b0ed6f9640
commit
9b56235de8
1 changed files with 11 additions and 5 deletions
|
@ -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)));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue