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 { Prng, mulberry32 } from "./lib/prng";
|
||||
|
||||
const BLOWUP = 4;
|
||||
const WIDTH = 240;
|
||||
const HEIGHT = 135;
|
||||
const BLOWUP = 4 * 5;
|
||||
const WIDTH = 240 / 5;
|
||||
const HEIGHT = 135 / 5;
|
||||
|
||||
type Lookup2d = (x: number, y: number) => number;
|
||||
function dim(width: number, height: number): Lookup2d {
|
||||
|
@ -104,12 +104,14 @@ export function IslandApplet() {
|
|||
|
||||
const islands = new IslandGrid(WIDTH, HEIGHT, 128);
|
||||
|
||||
function tick() {
|
||||
const pos = islands.rng() % islands.data.length;
|
||||
const basePos = islands.data.length >> 1;
|
||||
|
||||
islands
|
||||
.floodSearch(pos, (tile) => tile > 0)
|
||||
.forEach((pos) => islands.data[pos]++);
|
||||
function tick() {
|
||||
const islandTiles = islands.floodSearch(basePos, (tile) => tile > 0);
|
||||
|
||||
const pos = islandTiles[islands.rng() % islandTiles.length];
|
||||
|
||||
islands.data[pos]++;
|
||||
|
||||
renderIslands(islands, cx);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue