How do I make a room generation system?

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

Make a room generating system where everytime you open a door, a room generates behind the door, and there are random chances for a different type of room to appear. However, I want specified types of rooms to appear before a specific room number. Like cubicles generate before Room 20 and they stop generating after room 20. It should only generate at a specified x coordinate and not y coordinate.

What is the expected result

When game starts, you go to open a door, and when the door opens, a room generates. However, it shouldn’t be noticeable. It should be like you entered a normal room.

I already got the player, health system working, and I even have the spawn point ready. I also have an issue with the spatial sound, but that’s not too much to worry about as I only need to worry about the game mechanics. Sound can be last.

Anyways, any help is appreciated.


↓ You don’t have to read this btw ↓
(No don’t go out of your way to make an entire game just for me. I want to do this myself. However, just because I said that doesn’t mean I know how to do it. That’s also why I came here. I’m tired of communities being like “Oh well its not my problem, go learn lua” or “So then go make it and stop asking us for answers!!” I’ve had that happen to me in the Roblox studio discord server. It was also because of them that I gave up on making my Roblox game. Also some developer from the server also stole my idea there. I know they did because I explained my ideas there. It was suppose to be a Skinwalker game and if you go on Roblox today, you can even find a Skinwalker game on there. And, lua is complete garbage to learn. Like some of it doesn’t even go with Roblox studio. I am just a beginner. I can make a platformer game in Gdevelop easily. And in scratch, I can also make a tennis game easily. I love using scratch sometimes but my school is a jerk and blocked it. Gdevelop is fun to use, and my school doesn’t block it, which is real nice. And I know this is offtopic, and I’m sorry. Please understand. Thank you.)

(I’ve had to make a few edits because some of it was a bit messy and hard to read if you were wondering)

And for those who don’t know, the game is 2D and isn’t topdown. Its side-view. So it should generate rooms that aren’t topdown.

Here’s a step-by-step breakdown of how I would implement procedural generation in GDevelop using pseudo-code. Procedural generation can be complex, but here’s a simple approach:

  • First, I would create a random function that selects a room number from 1 to n, generating n scenes in total.
  • Next, I would design each room in the Tiled Map Editor and set them up as individual scenes in GDevelop.
  • When the player opens a door in the initial scene, the game would switch to the corresponding scene based on the randomly selected room number, or a specified room for that door.
  • This process can then iterate, randomly generating a new room each time the player moves to the next door, creating a procedural room generator.

As said, this will work just by changing the scene, and making random function described above.

In short premade rooms + randomization = procedural

Heres a way for any amount of rooms/inf rooms:

First, create a hidden hitbox for the first room wherever you want, maybe at the other half or close to the door, plus create another object to link it to it. We will use it to detect the original room.

Next, when it collides with said hitbox, pick a random number from 1 to n using RandomInRange(1,n). For the rarity system, then set a variable [ex: room] to the chosen number. Then:

If room = 1-N2, then set another variable to something to signify a room type. [ex: set Picked to Cubicle].

Then, just add/create the room object at the BoundingSideRight.X [assuming the door is on the right side of the room] of the original room, and make sure to add the hitbox again.

Finally, when the door is collided [or whatever you want the condition to be for entering a new room] play the animation of opening door, then when done make the player’s x add by [idk, 100?] for it to teleport/move right (the direction) to the other room, play the animation of slamming door, then delete the original room by finding the object that was linked to the detecting object. Finally, don’t forget to then link the new room to the detecting object.

Just duplicate the 3rd step and beyond for the other rooms, changing the rarity. Make sure to also edit the boundingbox side for other rooms, like rooms which are L’s, curving down or top.

Hope this helps!