3d-dungeon-generator 中文文档教程
3D Dungeon Generator
Installation
yarn add 3d-dungeon-generator
或者
npm install 3d-dungeon-generator
Basic Usage
const generator = new DungeonGenerator();
const { maze, rooms, corridors, stairs } = generator.generate({
seed: 'starter',
});
maze
is a 3D array representing different node types, useful for bitmaskingrooms
is an array of rooms with location/sizecorridors
is an array of corridors with a path array (x/y/z location)stairs
is an array of stairs with a path array and directional info
Parameters
{
seed: 'hello world', // Seeded RNG
roomCount: 4, // Max room count, not including predefined
roomSpacing: 1, // How many tiles between rooms
width: 16, // Max width of grid
height: 16, // Max height of grid
levels: 3, // Max amount of levels to generate
predefined: [{ // List of predefined rooms
location: {
x: 0,
y: 0,
z: 0,
},
size: {
x: 2,
y: 1,
z: 2,
},
}],
minRoomWidth: 3, // Min room width (x)
minRoomHeight: 3, // Min room height (z)
minRoomDepth: 1, // Min room depth (y aka levels)
maxRoomWidth: 6, // Max room width (x)
maxRoomHeight: 6, // Max room height (z)
maxRoomDepth: 1, // Max room depth (y aka levels)
overlapRooms: false, // Should rooms overlap on the y axis
allowStairs: true, // Stair generation insted of mineshafts
intersectCorridors: true, // Can corridors cross eachother?
cycleEdges: true, // Not yet used!
maxTries: 256, // How many attempts to generate a room
}
Tests
由于时间限制和这个库正在积极开发/试验中,还没有测试。 即将推出。
License
麻省理工学院
Credits
感谢@liady 提供图书馆入门工具包:https://github.com/liady/es6-lib-starter-light
3D Dungeon Generator
Installation
yarn add 3d-dungeon-generator
or
npm install 3d-dungeon-generator
Basic Usage
const generator = new DungeonGenerator();
const { maze, rooms, corridors, stairs } = generator.generate({
seed: 'starter',
});
maze
is a 3D array representing different node types, useful for bitmaskingrooms
is an array of rooms with location/sizecorridors
is an array of corridors with a path array (x/y/z location)stairs
is an array of stairs with a path array and directional info
Parameters
{
seed: 'hello world', // Seeded RNG
roomCount: 4, // Max room count, not including predefined
roomSpacing: 1, // How many tiles between rooms
width: 16, // Max width of grid
height: 16, // Max height of grid
levels: 3, // Max amount of levels to generate
predefined: [{ // List of predefined rooms
location: {
x: 0,
y: 0,
z: 0,
},
size: {
x: 2,
y: 1,
z: 2,
},
}],
minRoomWidth: 3, // Min room width (x)
minRoomHeight: 3, // Min room height (z)
minRoomDepth: 1, // Min room depth (y aka levels)
maxRoomWidth: 6, // Max room width (x)
maxRoomHeight: 6, // Max room height (z)
maxRoomDepth: 1, // Max room depth (y aka levels)
overlapRooms: false, // Should rooms overlap on the y axis
allowStairs: true, // Stair generation insted of mineshafts
intersectCorridors: true, // Can corridors cross eachother?
cycleEdges: true, // Not yet used!
maxTries: 256, // How many attempts to generate a room
}
Tests
Due to time limitations and this library being in active development/experimenting, there are no tests yet. Coming soon.
License
MIT
Credits
Thanks to @liady for the library starter kit: https://github.com/liady/es6-lib-starter-light