mz-terrain
v0.0.4
Published
terrain generator
Downloads
2
Readme
mz-terrain
Simple terrain generator by Diamond-square algorithm
It's just rewrite by coffeescript, Realistic terrain in 130 lines
How to use
npm install mz-terrain
Terrain = require 'mz-terrain'
terrain = new Terrain(7, 2) # detail, roughness
terrain.generate()
map = terrain.to2dArray()
for row in map
xs = row
.map (t) -> if t.val > 1 then '#' else ' '
.join ''
console.log xs
API
declare class Terrain {
constructor: (detail: number, roughness: number);
generate(): void;
toArray(): {x: number; y: number; val: number;}[];
to2dArray(): {x: number; y: number; val: number;}[][];
}
LICENSE
MIT