• 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!

GML Creating Procedurally Generated Persistant Rooms in a Side-Scroller

O

Omnivorish

Guest
First question, is this possible? If yes, does it require .ini? If no, Is there another way to go about it. I've attempted creating a template room with a procedural generation script, and it works fine. I've used both room_add then room_assign, and just plain room_duplicate. The downside to this is that you have to set a title for the new room, so the script can only be used once before it stops working, because it can't create a room that already exists. So that would be useful knowledge. Secondly, say the rooms work and I can make as many as I'd like, all procedurally generated with their own ids, if I tried to return to the room previous, would simply making it persistent work? If not, what would work?
 

NightFrost

Member
When you do your procedural generation, save the generated information into a data structure. This will be your only source of what a level should contain. When a level notices it needs to display more (most likely due to scrolling caused by player movement) it fetches information from this data structure and generates necessary room components. This way you don't even need to change rooms when switching a level, you simply wipe the slate clean, change level pointer and redraw according to new level's data (display a "loading screen" on topmost layer while this happens so player doesn't experience the redraw) . Room space should not be your data storage, as you'd have to make rooms persistent for the sole reason of not losing that data.
 
O

Omnivorish

Guest
@NightFrost First, Thank you so much for the quick reply. Secondly, I'm not very knowledgeable on data structures of ds related things yet. I believe I'm understanding your explanation a bit though. For my game, I want to at least give the illusion of switching rooms I guess, so would it be possible to generate the new "level" offscreen before the player reaches the end of the current screen, then panning over when the player reaches it?
 
D

Danei

Guest
Yes, you can do that. What I do in my procgen, single-room side scroller is draw the old "room" on a surface, then generate the new one, but invisibly, then draw that on a surface too, then I slide the first surface out of the view while sliding the second surface into it, and moving the player to the opposite side of the view, so it appears as though you are entering a new room. When the sliding is done, I destroy both surfaces and make the invisible layers visible again.
 
O

Omnivorish

Guest
Yes, you can do that. What I do in my procgen, single-room side scroller is draw the old "room" on a surface, then generate the new one, but invisibly, then draw that on a surface too, then I slide the first surface out of the view while sliding the second surface into it, and moving the player to the opposite side of the view, so it appears as though you are entering a new room. When the sliding is done, I destroy both surfaces and make the invisible layers visible again.
And you are able to return to the "room" prior with this method, sliding and all?
 
D

Danei

Guest
Yes, I store all the room info in a ds_grid of ds_grids, which I load in from a JSON ds_map.
 
O

Omnivorish

Guest
I hate to ask, but do you have example code, I've been looking through the GM Helper, but I can't figure it out. Or do you know any tutorial videos the handle procedural generation without vertical changes, I just want a flat ground, with procedurally generated things like trees or rocks.
Yes, I store all the room info in a ds_grid of ds_grids, which I load in from a JSON ds_map.
 
D

Danei

Guest
Well, to be honest I'm not sure where to even start with example code for you to look at. The way I do the actual generation is similar to Spelunky, where I take some templates stored as strings, read them from a text file, pick some randomly, and use a convoluted series of steps based on conceptual keys and locks to arrange them into a labyrinth and translate the strings into grids of tile indices. Then another convoluted series of steps to read the topography of the rooms and place features and enemies in sensible locations. If you're not entirely familiar with the use of data structures in gamemaker, none of that code is going to make any sense to you anyway, and it isn't built to dynamically produce features at runtime like you seem to want.
Plus, that code is entirely separate from the code for changing rooms; I generate the entire world at the start and store it in a grid before the gameplay begins.
 
O

Omnivorish

Guest
How, in your opinion, would you procedurally generate trees, in a flat endless scroller like this?
Well, to be honest I'm not sure where to even start with example code for you to look at. The way I do the actual generation is similar to Spelunky, where I take some templates stored as strings, read them from a text file, pick some randomly, and use a convoluted series of steps based on conceptual keys and locks to arrange them into a labyrinth and translate the strings into grids of tile indices. Then another convoluted series of steps to read the topography of the rooms and place features and enemies in sensible locations. If you're not entirely familiar with the use of data structures in gamemaker, none of that code is going to make any sense to you anyway, and it isn't built to dynamically produce features at runtime like you seem to want.
Plus, that code is entirely separate from the code for changing rooms; I generate the entire world at the start and store it in a grid before the gameplay begins.
 

Attachments

O

Omnivorish

Guest
Well, to be honest I'm not sure where to even start with example code for you to look at. The way I do the actual generation is similar to Spelunky, where I take some templates stored as strings, read them from a text file, pick some randomly, and use a convoluted series of steps based on conceptual keys and locks to arrange them into a labyrinth and translate the strings into grids of tile indices. Then another convoluted series of steps to read the topography of the rooms and place features and enemies in sensible locations. If you're not entirely familiar with the use of data structures in gamemaker, none of that code is going to make any sense to you anyway, and it isn't built to dynamically produce features at runtime like you seem to want.
Plus, that code is entirely separate from the code for changing rooms; I generate the entire world at the start and store it in a grid before the gameplay begins.
I figured it out!!!! Thank you for all your help!!!
 
Top