1.0.6 • Published 7 years ago

dungeon-factory v1.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

dungeon-factory

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/

Installation

Install dungeon-factory by running:

$ npm install --save dungeon-factory

Usage

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.

License

The project is licensed under the MIT license.

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3-a

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago