1.0.32 • Published 7 years ago

random-dungeon-generator v1.0.32

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

###Random Dungeon Generator

total downloads Travis version license Code coverage

Create a Random Dungeon using a procedural dungeon generator. Based on a BSP Tree algorithm http://www.roguebasin.com/index.php?title=Basic_BSP_Dungeon_generation

##Simplest Example

// create new dungeon with default width, height, max and min room size
const dungeon = NewDungeon({});
// with options
const options = {
    width: 50,
    height 50,
    minRoomSize: 5,
    maxRoomSize: 20
};
const dungeon = NewDungeon(options);

Returns a 2d array with the values: "1" is a blocking/wall tile Every other number denotes a different room. For example:

const dungeon = [
    [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,6,6,6,6,6,6,6,6,6,6,6,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,6,6,6,6,6,6,6,6,6,6,6,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,6,6,6,6,6,6,6,6,6,6,6,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,6,6,6,6,6,6,6,6,6,6,6,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,6,6,6,6,6,6,6,6,6,6,6,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,6,6,6,6,6,6,6,6,6,6,6,1,]
    [1,2,2,2,2,2,2,2,2,2,0,0,0,0,6,6,6,6,6,6,0,6,6,6,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,0,1,1,0,0,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,0,1,1,1,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,7,7,7,7,7,7,7,0,7,7,7,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,2,2,2,2,2,2,2,2,2,2,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,2,2,2,2,2,2,2,0,2,2,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,1,1,1,1,1,1,1,0,1,1,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,1,1,1,1,1,1,1,0,1,1,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,3,3,3,3,3,3,3,0,3,3,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,3,3,3,3,3,3,3,3,3,3,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,3,3,3,3,3,3,3,3,3,3,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,3,3,3,3,3,3,3,3,3,3,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,3,3,3,3,3,3,3,3,3,3,1,1,7,7,7,7,7,7,7,7,7,7,7,1,]
    [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,]
];

Here, 1. The 1's are walls (the borders of the rooms) 2. The 0's are the corridors (the pathways that join the rooms) 3. The other numbers (2, 3, 6, 7) represent different rooms. The numbers are arbitary, and just count upwards.

1.0.32

7 years ago

1.0.31

7 years ago

1.0.30

7 years ago

1.0.29

7 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

7 years ago

1.0.23

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago