Text Dev Log #1 - Procedural Level Generation



Hello everyone :D

Welcome to my Text DevLog #1 and today I will explain a little about the way the levels will be generated on The Mercenary Path, so get be comfortable and enjoy :D

One of a important part of a roguelike game is the level generation. In order to make the game repeatable the levels need to be different everytime. 

Thinking about it, I started to research ways to learn and implement this and came across some articles. One of those articles caught my attention where the author explain about fundamentals and different approachs to achieve this behavior. You can read the article at https://pavcreations.com/procedural-generation-of-2d-maps-in-unity/.

Together with that I found an amazing tutorial lessons from Blackthornprod on youtube and there he explains how  to implement following the idea from the game Spelunky.

Basically the idea is to have a board matrix with 4 rows and 4 columns, rooms with opening from left, right, top or bottom and navigate between this board, placing a random room, with a final result of a board with different rooms.

So following this idea I decided to implement with a different approach. Using a board with 3 columns and 5 rows, with first row only for starters roomsand the last row for the final rooms and 3 central rows for the other rooms that compose the level progression.


Now before I describe more how the board is created, let's talk about the rooms. For it I created 6 types of rooms: Starter rooms with only bottom door, final rooms with only top door and for the center rooms, 4 types of rooms with doors on Left-Right, Left-Right-Top, Left-Right-Bottom, Left-Right-Top-Bottom,  Top and Bottom.

Finally we can talk how the generation process happens. First the LevelGenerator script decide which starter position to begin with a random from 0 to the total number of start positions array. In this part only rooms with type BOTTOM are selected. After the initial room is added, the script move to the next row and choose a room that has a connection that can be linked with the previous room generated. In this case we avoid problems of rooms without doors or non path for player from the start to final room :)

During the placement of rooms on center positions, the script can move down, left or right, when arriving on the final room row, it check where the last center room was created and create the final room beneath it. The following diagram can illustrate better the idea:


After all the path rooms are placed, from start to final, the remaining positions generate a room to create other possible paths for the player. When all the rooms are places and the board is created, we check the doors to add doors or walls to block the player to get out of the board.

That's it, simple and fun to do it :D Another interesting thing that you can do to increase the randomness of the generation is to create different types of the same room, for example 3-4 options for a starter, center and final rooms.

So to finish thank you so much for reading my first dev log and if you have any question/feedback please feel free to comment or reach me :D

Don't forget to follow us in our social networks:
- Instagram: https://www.instagram.com/themercenarypath/
- Twitter: https://twitter.com/DeKoServidoni

Stay tunned for next updates about The mercenary path and see you in the next post! :D :D

Leave a comment

Log in with itch.io to leave a comment.