Pick random tile in floodsearch to elevate
This commit is contained in:
parent
5e87ba9380
commit
3b701019cc
1 changed files with 10 additions and 8 deletions
18
island.ts
18
island.ts
|
@ -1,9 +1,9 @@
|
||||||
import { canvas2d } from "./lib/html";
|
import { canvas2d } from "./lib/html";
|
||||||
import { Prng, mulberry32 } from "./lib/prng";
|
import { Prng, mulberry32 } from "./lib/prng";
|
||||||
|
|
||||||
const BLOWUP = 4;
|
const BLOWUP = 4 * 5;
|
||||||
const WIDTH = 240;
|
const WIDTH = 240 / 5;
|
||||||
const HEIGHT = 135;
|
const HEIGHT = 135 / 5;
|
||||||
|
|
||||||
type Lookup2d = (x: number, y: number) => number;
|
type Lookup2d = (x: number, y: number) => number;
|
||||||
function dim(width: number, height: number): Lookup2d {
|
function dim(width: number, height: number): Lookup2d {
|
||||||
|
@ -104,12 +104,14 @@ export function IslandApplet() {
|
||||||
|
|
||||||
const islands = new IslandGrid(WIDTH, HEIGHT, 128);
|
const islands = new IslandGrid(WIDTH, HEIGHT, 128);
|
||||||
|
|
||||||
function tick() {
|
const basePos = islands.data.length >> 1;
|
||||||
const pos = islands.rng() % islands.data.length;
|
|
||||||
|
|
||||||
islands
|
function tick() {
|
||||||
.floodSearch(pos, (tile) => tile > 0)
|
const islandTiles = islands.floodSearch(basePos, (tile) => tile > 0);
|
||||||
.forEach((pos) => islands.data[pos]++);
|
|
||||||
|
const pos = islandTiles[islands.rng() % islandTiles.length];
|
||||||
|
|
||||||
|
islands.data[pos]++;
|
||||||
|
|
||||||
renderIslands(islands, cx);
|
renderIslands(islands, cx);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue