In my previous blogpost ( Making Random Maps Fun ) I told about the map generator and how I wanted to change it to make the maps more rewarding and fun to explore. Now it is finished! Let me show you the progress with some screenshots:
The previous map generator randomly placed a set amount of rooms all over the map and connected them with corridors. This could result in corridors leading from one corner of the map to another corner of the map. Mostly the maps were like the screenshot above. Some random rooms and lots of corridors. Doesn’t make sense and isn’t a lot of fun to explore.
I started with generating the main path. All the rooms on this path need to be traversed to reach the exit, you know for sure that the player is going to visit these rooms. The map generator starts with randomly placing one room. Then it picks a random side of that room and it tries to spawn a new room there. This process continues until we have reached the room limit as set in the settings.
Next up are the medium difficulty rooms ( I filled them with spiders to show which rooms i’m talking about ). These maps aren’t necessary to reach the next level, they are optional and contain more monsters and loot. This way it’s possible to reward the player for going of the main path. For example it’s also possible to lock one or more of these rooms and place key’s on the main path as the player can always get the key that way.
I also made sure that if the map generator got stuck at a certain point, when it can’t place a room in any direction, it continues anyway. I did this by programming the generator to go back one room when this happens. The room that can’t expand in any direction is labeled as a medium room, and we try to continue the main path from the previous room. This process can also take place a few times per generation to allow the generator to go back a set number of rooms.
The last step is adding hard difficulty rooms ( Skeleton filled rooms ). These rooms are only placed at the end of one or multiple medium rooms. This way they are the hardest to reach but also the most rewarding if you manage to enter one.
The map generator is now highly configurable and can create lots of different maps. An example of some settings are: maximum hard rooms, room spacing, maximum tries before failing, etc.
Here are some more examples of the new maps:
If you are interested in the code I would like to remind you that the code for the entire game is open source and on my GitHub! Specific map generator code can be found here.