Skip to content

j0t3x/dungeon-factory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Procedural dungeon generator

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.0%
  • HTML 1.0%