• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 11 years ago
  • Updated about 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript port of Amit Patel's mapgen2 https://github.com/amitp/mapgen2

voronoi-map-js

JavaScript port of Amit Patel's mapgen2 https://github.com/amitp/mapgen2 Map generator for games. Generates island maps with a focus on mountains, rivers, coastlines.

Based on commit: e05075cbb82851e2a3bacaa2e49e4da998894379

Flash dependencies removed.

Built with JavaScript, Node.js, JQuery, Lo-Dash, Browserify, UglifyJS, Nodeunit, Sublime Text.

Try the demo

Install me from NPM

Fork me on GitHub

Installation & usage

Using npm:

npm install --save voronoi-map

In CommonJS / Browserify:

var PIXI = require('pixi.js');

var islandShape = require('voronoi-map/src/island-shape');
var lavaModule = require('voronoi-map/src/lava');
var mapModule = require('voronoi-map/src/map');
var noisyEdgesModule = require('voronoi-map/src/noisy-edges');
var pointSelectorModule = require('voronoi-map/src/point-selector');
var renderCanvas = require('voronoi-map/src/render-canvas');
var renderPixi = require('voronoi-map/src/render-pixi');
var roadsModule = require('voronoi-map/src/roads');
var style = require('voronoi-map/src/style');
var watershedsModule = require('voronoi-map/src/watersheds');

var map = mapModule({width: 1000.0, height: 1000.0});
map.newIsland(islandShape.makeRadial(1), 1);
map.go0PlacePoints(100, pointSelectorModule.generateRandom(map.SIZE.width, map.SIZE.height, map.mapRandom.seed));
map.go1BuildGraph();
map.assignBiomes();
map.go2AssignElevations();
map.go3AssignMoisture();
map.go4DecorateMap();

var lava = lavaModule();
var roads = roadsModule();
roads.createRoads(map, [0, 0.05, 0.37, 0.64]);
var watersheds = watershedsModule();
watersheds.createWatersheds(map);
var noisyEdges = noisyEdgesModule();
noisyEdges.buildNoisyEdges(map, lava, map.mapRandom.seed);

// render with Canvas Context 2D

var canvas = document.createElement('canvas');
renderCanvas.graphicsReset(canvas, map.SIZE.width, map.SIZE.height, style.displayColors);
renderCanvas.renderDebugPolygons(canvas, map, style.displayColors);

// or render with Pixi / WebGL

var context = { renderer: new PIXI.autoDetectRenderer() };
document.body.appendChild(context.renderer.view);
renderPixi.graphicsReset(context, map.SIZE.width, map.SIZE.height, style.displayColors);
renderPixi.renderDebugPolygons(context, map, style.displayColors);
context.renderer.render(context.stage);

In vanilla JavaScript, all modules are exported to global voronoiMap object :

<script type="text/javascript" src="voronoi-map.min.js"></script>
<script type="text/javascript">
	
	var map = voronoiMap.mapModule({width: 1000.0, height: 1000.0});
	...
</script>

Tasks

  • fix smooth rendering bug for square point selection
    • canvas-render.js ~line 300, problem is with graphics.stroke() original render logic only draws fill paths. HTML canvas fill path does not join other paths and shows a seam between them. stroke() worked to hide the seam but square point selection exposes a bug where some strokes are not the correct color
  • fix point-selector square and hexagon so distribution is symetrical when size is asymetrical
  • pixi WebGL rendering is quite slow, too slow for animation
    • moving some of the rendering functions into GLSL shaders would help, especially the noisy edges parts

More Repositories

1

vice.js

Versatile Commodore Emulator for JavaScript
Shell
150
star
2

voronoi-map-haxe

Haxe port of Amit Patel's mapgen2, a procedural terrain / map generator.
Haxe
71
star
3

janicek-core-haxe

My personal collection of Haxe core libraries.
JavaScript
21
star
4

bos

Big Object Store - loads, watches, and progressively saves changes in a JavaScript object to disk. Designed for node.js. Can be used as a simple database.
JavaScript
18
star
5

liquidfun-rust

Rust bindings for LiquidFun.
C++
14
star
6

connectwise-action-api

A thin high performance JavaScript layer for the ConnectWise XML Action API designed for Node.js.
JavaScript
8
star
7

mocha.js-haxe

Haxe bindings for mocha.js & expect.js - simple, flexible, fun javascript test framework for node.js & the browser. (BDD, TDD, QUnit styles via interfaces)
JavaScript
7
star
8

pixi-noise-filter

A noise filter for pixi.js
JavaScript
7
star
9

connectwise-manage-rest-api

A lightweight interface that preserves the syntax but removes as much boiler plate code as possible for using the ConnectWise REST API's.
JavaScript
6
star
10

leveldb-node-haxe

Haxe bindings for LevelDB Node.js modules. LevelUP, and Multilevel.
JavaScript
5
star
11

jasmine-haxe

Haxe bindings for Jasmine, a behavior-driven development framework for testing your JavaScript / Haxe code.
JavaScript
5
star
12

async.js-haxe

Haxe bindings for async.js - Async utilities for node and the browser.
JavaScript
4
star
13

templates

Curated list of my development tools, libraries and processes.
JavaScript
3
star
14

Safe2D

Safe2D - Form Encryption - Chrome Extension
JavaScript
1
star