So for the past few days I've been having fun making a basic procedural map generator for a 2d sidescroller (kinda like terraria),
here is what I got so far https://dl.dropboxusercontent.com/u/55828593/RandomMap/index.html might take a while to load, press F5 to get a different result.
Basically, it's a 2D array used as a "tilemap".
I set up my array values with different stuff then create sprites for Each array XY at (Array.CurX,Array.CurY) depending on the array value at those points.
But when I try to expand the Array width too much (cause I want a big level/open world), the game will crash and won't even load.
Probably cause too many sprite/objects are created (If I remove the process of spawning the sprites the game will load fine, so it can generate the array but not create that many sprites).
So I'm trying to find a way to "spawn" things on the fly.
I've thought about spliting my layout into different zones on the X axis.
For example if player is in zone 4, it will only spawn the sprites for the zone 3, 4 and 5. If player go to zone 5, it will spawn the sprites into zone 6 and destroy the sprites into zone 3.
When a player is in x zone, only sprites in x-1, x and x+1 zones will be created. You get the idea?
I'm not even sure if it can spawn that many sprites fast enough without getting some lag but it might work (if I make the zones small enough maybe).
The thing is I have no idea how I could do that, I was thinking of another array to make the zones but I'm not sure how to implement it.
That's why I'm asking you for help.