- Home /
Implementing a dungeon rogue-like floor.
Wall of text, sorry.
Ok, so what I'm trying to create is a single floor that is very similar to the floors in games like Binding of Isaac or Enter the Gungeon. The way that I wish to do this is by using pre-made rooms and attaching them together randomly in order to create a floor, while including one starting room and one boss room. All of the tutorials I've seen online use randomly generated, not pre-made rooms, which is why I'm asking here.
Here is the overall structure of the code that I thought of using to make a floor:
1) First create the pre-made rooms and corridors by arranging sprites to simulate walls and things and add tags to everything for the rooms (for example, all the enemies, walls, etc. for room1 will have the tag "Room1").
2) When game starts, create a list of random rooms that will be used for the floor (containing around 15-ish rooms). This list must include "Room1" and "BossRoom".
3) The code will now add room1 by enabling all objects with the tag "Room1". Remove "Room1" from the list (to ensure that room1 isn't used again).
4) Randomly open some exits of the room. For every exit opened, attach a corridor and a random room from the list by enabling all objects with the room tag and shifting the position of the objects accordingly. (Since the number of corridors in a floor will be one minus the number of rooms on a floor, I can use a count variable to make sure that there aren't too many opened exits).
5) Check for overlap between rooms/corridors. If there is, delete the last room and repeat step 4 until no overlaps are found. Delete the added rooms from the list.
6) Repeat steps 4 and 5 until the list of rooms is empty.
I have even started created some of the code, but I'm wondering if I'm working "harder, not smarter." Is there an easier or more efficient way to do what I'm trying to accomplish? Does this method have any problems that might bite me in the butt later?
//////////////////
TLDR: Is the procedure above an efficient way to implement a rogue-like dungeon floor?
Other questions: How would I make it so that the boss room isn't too close to the starting room? What if I wanted to make the boss room always be in the center of the floor; how would I code that (this sounded easy in my mind, but since the center of the floor is relative to all of the other rooms, not the actual center position, the center would change based on how the rooms are organized in the end)?
Your answer
