• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [HELP] Create a dungeon with premade rooms

RedP

Member
Hi, i'm trying to create random dungeons with premade rooms, i created a ds_grid with the total of rooms that can be generated, but i don't understand how can i set where each room need to be placed in the grid. I feel completly lost, already read a few tutorials and gamamaker docs, but can't figure out how to actually code it, if someone at least give me some light and the process to make it work would help so much.

Thank you!!
 

NightFrost

Member
The basic idea in Spelunky-style dungeons is having a number of prefabricated room templates stored in some manner. Imagine for example a 11x11 cell grid. At its simplest, you would set each grid cell either to zero to indicate an empty tile, or to one to indicate a wall tile. When a prefab piece is used to build a dungeon, the constructor would loop through every cell and set a wall pieces at designated spots. The steps inside the room would depend on your tile sprite sizes. If it were 32x32 pixels, the constructor loop would step the creation location 32 pixels every time it jumps to next grid cell.

To construct an entire dungeon of these prefab pieces, you'd first initialize another grid. Then you'd fill it with IDs of the prefab pieces, either completely randomly or according to some algorithm. After that loop through the grid, fetch the prefab piece data and construct the dungeon piece by piece as explained above. Important thing is to construct your prefab pieces according to some guideline so they all fit together at the edges.

One method I've used for this is maze generation algorithms. It would first create a maze on for example a 8x8 grid, and then I would pick suitable prefab room based on where the exits on each maze cell lie.
 
Top