This tutorial focuses on another algorithm to generate dungeons: Those to create dungeons with large areas.
Create more Snippets
We need some new snippets to draw those dungeons.
- 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.
The first 9 snippets are straight-forward. Then, snippets within the two bottom rows define inner corners and two double inner corners.
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.
Well, I admit, this map looks confusing. There are all the snippets having an area and a tunnel on this map. 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.
Entrance and Exit
Add some region Ids to place entrance and exit as we already did before.
Set the Space Map’s as the Parent Map for the other Maps.
By the way, it is possible to create multiple maps for the area and/or transitions, just as we did before with the tunnel snippets.
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 that the 2nd command is the only one that is different from the ones we used before. In the future, more algorithms with more optional arguments will be provided.