This module is a tool for generating random dungeons as a two dimensional array. It is largely based on the excellent work of Bob Nystrom and his game Hauberk, which you can read about here.
A demo of this module can be seen here https://lucianbuzzo.github.io/dungeon-factory/
Install dungeon-factory
by running:
$ npm install --save dungeon-factory
Require in the factory and then call the generate
method,
using an object containing a width
and height
attribute.
The width
and height
attributes determine the size of the dungeon and should
always be odd numbers.
const DungeonFactory = require('dungeon-factory');
const dungeon = DungeonFactory.generate({
width: 21,
height: 21
});
The generate
method will return a two dimensional array of Tile objects
Tile {
type: 'wall',
neighbours: [
[Object], [Object], [Object], [Object], [Object]
],
nesw: {
north: [Object],
south: [Object],
east: [Object],
west: [Object]
}
}
- type - The tile type, can be one of 'wall', 'floor' or 'door'.
- neighbours - An array containing the tiles immediately surrounding this one.
- nesw - An object containing the tiles immediately north, south, east, and west of this tile.
The project is licensed under the MIT license.