BSP

BSP

Binary Space Partitioning

Constructor

new BSP(width, height, options)

Source:
Example
let bsp = new Bsp(30, 20);
bsp.calculate();

for (const r of bsp.rooms) {...}
for (const r of bsp.corridors) {...}
Parameters:
Name Type Description
width Number

width of the base rectangle

height Number

height of the base rectangle

options Object
Properties
Name Type Description
padding Number

space between the rooms

roomMinSize Number

minimum room size

roomMaxSize Number

maximum room size

rand SeededRandom

random instance

Methods

calculate()

Source:

Calculate it