Load and unload procedurally generated world

I want to make a procedurally generated world (top-down Dungeon crawler like game) And I’m using the Dungeon generator extension.

I left the “delete unused Terrain” off since I need the extra terrain for the player to mine.

This slows down the game tremendously.
My initial approach was hiding any tiles that are further than X distance from the player and showing them when they are Within X distance.

However, this doesn’t help much.

Is there a way to use the storage system to save the location of every individual tile after the world is created, and then delete the tiles that are further than X distance from the player?

Then re-create those tiles when they are within X distance of the player.

I have a good feeling this will help tremendously if It’s possible and If I can implement it.

Any suggestions on how to approach this?

Ty

I’d say you are probably going at it the wrong way. The dungeon generator makes, well, a dungeon, a small set of interconnected rooms. It sounds like you want to make a large (possibly infinite?) set of galleries in a mine. For that, I think you shouldn’t generate them all at once, but generate then as you go, that way you don’t generate and load in areas that the player is not even going to explore.

But then, that’s not really answering your question and I don’t really know anything about procedural generation :stuck_out_tongue:

For the performance, I’d try to check with the profiler (in the debugger) what exactly is causing the performance drops. It probably it is your events, try adding conditions that filter out objects far away from the player so that they are not being taken into account by your events, allowing them to run faster. Appart from that objects that are out of screen are not rendered anyways, so deleting them wouldn’t do you much if any good.

1 Like

Another totally different idea could be to use “Marching Squares” type of terrain digging instead of digging through sprite objects.
In Gdevelop, click browse templates from the home screen, and search for “Marching Squares”. Try out some of those templates to see what I mean.
You could do a hybrid approach too: you can dig through wall sprites generated by dungeon generator, but use “Marching Squares” terrain digging for all the dirt in between rooms.

1 Like