Random dungeon generation

Teo

Member
Hello, I am right now trying to make a random dungeon generation for my game. I have followed a video on YouTube and it is the system that I am using now. However I would like to have rooms in the game. So here is how I think I would do it but I don't really know if it is possible to program. I would spawn a starter room then I would have a couple of point in that room where it spawns another room and that goes on until there are a set amount of rooms. The thing I can't figure out is how do I make presets of rooms and how do I spawn them?
 
Can you link to the tutorial you are following? It would help give a better solution. I'd imagine you are following something like HeartBeast's dungeon generation tutorial. So I'll base my answer off of that.

If each room is generated at room start, than you have a lot of freedom in how to approach this. The easiest way would be to randomly place an exit in the dungeon room, this exit will take you to another floor/room, in order to allow for multiple rooms you can create the rooms as needed.

room_add() is used to create rooms during runtime. It'll create an empty room, make sure to assign the return value to a global variable. You could use an array to hold multiple room ID's in case you wanted to allow for going back to previous rooms (in that case, set the rooms to persistent.) After you create the room, just use room_goto() and than call whatever script you use for generating the dungeon, call it as soon as you enter this room.

With this approach, you could create a nearly infinite amount of rooms. Now, if you wanted these rooms to connect in a more complex manner, that would be significantly more challenging and would require dungeon generation code that encompasses multiple rooms and larger complex structures.
 
Top