GithubHelp home page GithubHelp logo

nannal / dungeoneer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lucianbuzzo/dungeoneer

1.0 1.0 0.0 1.35 MB

Generate beautiful 2d dungeons

Home Page: https://lucianbuzzo.github.io/dungeoneer

JavaScript 100.00%

dungeoneer's Introduction



Build Status npm version Dependency Status

Dungeoneer

Procedurally generate beautiful 2d dungeons for your game.
https://lucianbuzzo.github.io/dungeoneer



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/dungeoneer/

Installation

Install dungeoneer by running:

$ npm install --save dungeoneer

Usage

const dungeoneer = require('dungeoneer')

const dungeon = dungeoneer.build({
  width: 21,
  height: 21
})

The build method accepts width and height options that define the size of the dungeon, and will return a dungeon object. The smallest possible size for a dungeon is 5 x 5. Dungeons are always an odd size due to the way walls and floors are generated. If you supply even sized dimensions, they will be rounded up to the nearest odd number. The shape of the dungeon object is defined below:

type Tile = {
  // An object containing the tiles immediately surrounding this tile.
  nesw: {
    n?: Tile;
    ne?: Tile;
    e?: Tile;
    se?: Tile;
    s?: Tile;
    sw?: Tile;
    w?: Tile;
    nw?: Tile;
  };
  x: number;
  y: number;

  // 'floor' and 'door' are passable terrain and a wall is impassable terrain.
  type: 'wall' | 'floor' | 'door';
}

type Room = {
  height: number;
  width: number;
  x: number;
  y: number;
}

type Dungeon = {
  rooms: Room[];
  tiles: Array<Tile[]>;
  seed: string | number;
}

Seeding

A dungeon can be seeded using the seed option. A dungeon created with a seed and the same options can be repeatably created. Dungeons always return the seed they were created with.

const dungeoneer = require('dungeoneer')

const dungeon = dungeoneer.build({
  width: 21,
  height: 21,
  seed: 'foobarbaz'
})

License

The project is licensed under the MIT license.

The icon at the top of this file is provided by svgrepo.com and is licensed under Creative Commons BY 4.0.

dungeoneer's People

Contributors

lb-vb-in-a-box[bot] avatar lucianbuzzo avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.