Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Procedurally Generating/Loading Huge Maps

Author
Message
Alaror
15
Years of Service
User Offline
Joined: 9th May 2011
Location:
Posted: 11th Jun 2011 20:45
I'm working on a 2d game that requires very large maps with destructible terrain that is procedurally generated. Right now I'm wondering what the most efficient method would be to do the following:

1. Procedurally decide what type of block each terrain space should be before the game starts. I'm thinking about using a large matrix which would store an integer for each block type. I would need to be able to break it up into sections once the logic portion of generation is done and I'm not sure if you can do that with a matrix.

2. Load and save terrain data as the player gets near it. The plan right now is to break the entire world into chunks of equal size (1000x1000 blocks) and load the data for each chunk as the player gets near it. All object data would be stored in an array that lists the object type and their X/Y coordinate. Sprites would be created when a chunk is loaded and deleted when a chunk is unloaded. Is there a better way to do this than I described?

3. Storing possible collision locations. I was thinking of creating an array that contained all "solid" blocks that were currently loaded which the game could search through to see if there's a collision, but that seems inefficient.


I'm still learning the ropes, so any other advice you might have on the subject is much appreciated.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Jun 2011 02:12
Quote: "I'm thinking about using a large matrix which would store an integer for each block type. I would need to be able to break it up into sections once the logic portion of generation is done and I'm not sure if you can do that with a matrix."

you mean like the dbpro grid matrix right? Just use a 2d array!

As for chunk size, I'm trying to make a similar system right now using 64x64 chunks. I'd make the size a bit smaller. So, I load the current chunk the player is in, and the 8 chunks around that so that transitions between play areas will be seamless.

In my design, the character is a circle, radius 2, so collision is easy to handle - it's just with adjacent blocks. So, to be on the safe side, I just handle collision with blocks in a 4x4 square around the player. I'm storing collision data for all 9 loaded chunks, (9*64*64 points of collision data), but only checking collision with adjacent blocks.

As for the procedural generation thing... I haven't gotten there yet, I'm still working out quirks with the above two points. However, procedural generation is... a lot of fiddling around. You'll probably want to check out perlin noise as a starting point:
http://forum.thegamecreators.com/?m=forum_view&t=173396&b=1

so... what I'm doing is: generate or load terrain data as the player approaches it, then save/unload the chunk if the player walks far enough away from it, all the while checking collision with adjacent blocks only.


Why does blue text appear every time you are near?

Login to post a reply

Server time is: 2026-07-10 22:54:53
Your offset time is: 2026-07-10 22:54:53