Procedural Random Dungeon Generator – Tutorial Part 2

In this tutorial we focus on another algorithms to generate dungeons: Those to create dungeons with large areas.

Inside a Vulcano, containing tunnels, areas and lava
Look at the Minimap!

Create more Snippets

To draw those dungeons we first need some new snippets.

  • Those to draw large areas, including edges, corners, inner corners
  • Those to draw the connections between tunnels and areas, called Transitions

Let’s create the snippets for the areas. We create a new Map with the width of 3 * snippets_width + 4 and height of 5 * snippets_height + 6, in our case this will be 25 x 41.

Draw snippets as shown in this picture.

This picture defines how the snippets needs to be drawn

The first 9 snippets are straight-forward. Then, then snippets within the two bottom rows define inner corners and two double inner corners as special case.

Now, create another Map in which we create the Transitions. This map will have the same dimensions as the map in which we drew our tunnels, so let’s just copy-paste this map. Erase all the snippets and draw new ones as shown below.

Snippets for Transitions

Well, I admit, this map looks confusing. On this map there are all the snippets having an area and a tunnel. A tunnel can fade into an area at its corner or edge, horizontal or vertical, or even two tunnels can fade into an area at the same spot, leading to many possibilities.

Placing some doors will look really cool for sure 😉

Entrance and Exit

Add some region Ids to place entrance and exit as we already did before.

Connecting Maps

Go into Space Map’s setting and edit its note tags as follows:
<load:[
{"name":"snippets", "map":1},
{"name":"snippetsArea","map":2},
{"name":"snippetsTransitions","map":3},
{"name":"entrance_exit","map":4}
]>
<regions:
{"entrance_exit":{"w":1, "h":2}
>

Please adjust the numbers correctly to your maps.

By the way, it is possible to create multiple maps for area and/or transitions, just as we did before with the tunnel snippets. A settings could look like this:

{"name":"snippets", "map":1},
{"name":"snippets2", "map":2},
{"name":"snippetsArea","map":3},

{"name":"snippetsArea2","map":4},
{"name":"snippetsTransitions","map":5},

{"name":"snippetsTransitions2","map":6},
{"name":"entrance_exit","map":7}

Script Command

Now, when we write the command to finally generate our dungeon, we use this command:

$dungeonGenerator.randomWalk()
.generate()
.placeEntranceOn("bottom")
.placeExitOn("top")
.drawDecorations()
.finalize();

You probably noticed, the 2nd command is the only one which really differs from the ones we used before. In the future more algorithms with more optional arguments will be provided.

Conclusion

When everything went right, you will now create a dungeon using a Random Walk algorithm. Don’t forget you can always check out my thread in the forum and you can always contact me via PM when you encounter any issues 😉

Best Regards
Aero

Leave a comment

Your email address will not be published. Required fields are marked *