Repository navigation
MiscDungeonGenerator
Julien Samama edited this page Apr 10, 2014
·
1 revision
Generate a new dungeon and print it:
// building and printing
var dungeonBuild:MiscDungeonGenerator= new MiscDungeonGenerator();
dungeonBuild.generate(80, // map width
80, // map height
200, // fail, the higer the value of fail, the greater the chance of larger dungeons being created
5, // corridors
60); // max rooms
dungeonBuild.print();Get a specific tile:
dungeonBuild.mapArr[y][x];Loop through all tile to feed your Tilemap:
for (y in 0...dungeonBuild.mapHeight)
{
for (x in 0...dungeonBuild.mapWidth)
{
if (dungeonBuild.mapArr[y][x] == 0) // walkable area
{
// setTile(x, y, 0);
}
else if (dungeonBuild.mapArr[y][x] == 1) // out of the dungeon
{
// setTile(x, y, 0);
}
else if (dungeonBuild.mapArr[y][x] == 2) // wall
{
// setTile(x, y, 0);
}
else if (dungeonBuild.mapArr[y][x] == 3) // opened door
{
// setTile(x, y, 0);
}
else if (dungeonBuild.mapArr[y][x] == 4) // closed door
{
// setTile(x, y, 0);
}
else if (dungeonBuild.mapArr[y][x] == 5) // secret door
{
// setTile(x, y, 0);
}
}
}Go through each room:
for (room in dungeonBuild.roomList)
{
room[0]; // room height
room[1]; // room width
room[2]; // room x position
room[3]; // room y position
}Go through each corridor:
for (corridor in dungeonBuild.cList)
{
corridor[0]; // reference number to roomList
corridor[1]; // start x position
corridor[2]; // start y position
corridor[3]; // heading (0 = North, 1 = East, 2 = South, 3 = West)
}- Check the
makePortal()function if you want to change or add more types of doors (hole in the wall, opened door, closed door, secret door). - If you want the starting room, from where the algorithm built everything, it's the first room in the
mapArrarray. The array is sorted from the first room created to the last one.