Hello, guys,
How can i do a chunked map(or a tilemap game) ? Can it optimize my game ?
Thx,
Brian22950
I don’t think it’d be worth it. You’ll go a long way with a simple multidimensional array. Of course, you could legitimately benefit from a chunked map. I just have a feeling this is not the case.
Chunking a map / world makes ONLY sense when you either:
-have memory problems
-performance problems
For this to happen you needs to handle a lot of Data (Terrain, structures) or render too many Objects.
See the chunking just as a way to only load and process the part of your world wich is
currently of any interest for the gamelogic.
Other parts of your gameworld wich are too far away dont need to be loaded or can get discarded.
A very simple (and standard) example of “chunking” is to load a new level in a platformer.
You would not load and display all levels at gamestart…
A dynamic example is to split the world into smaller Cubicles, and load only the
next 20 cubicles wich are close to the player.
When the player moves around, some of the cubes get unloaded, and others wich some closer
get loaded.
But beware that this also means, that the non loaded cubicles should not be
of any relevance to the AI or collision detection. Anything happening there should be “frozen”
…
Only implement that if you really need it.
Or:
-you’re generating the world on the fly.
Although if you’re feeling pedantic you could possibly group that into ‘memory problems’ as it’d be impractical to generate it all at once.
memory and performance, you dont want to search and cull 99% of unused elements.
its basically just a method to limit the “scope of relevance”
Also works good for Pathfinding on huge maps, when you dont need to have long walks to be calculated.
I did something like this once:
After probably spending a full week or more getting it to work and all of the side-effects (e.g. loading/saving) I ended up taking it out. It added too much complexity for its benefit.
Unless your game is a sandbox game like Minecraft then too large of a world map (or a continuous one) is a drawback. It’s next to impossible to add enough meaningful content for the player.
Diablo 3? Has a bunch of chunks, and they get strapped together randomly. It’s not a bad idea if you want a sort of consistency but also want the player to have a different experience each play-through.
If we’re talking about a JRPG game, you could have towns as static locations, but randomize the connections between the different chunks of map. You could even have each area be basically the same with mountains and such, but the roads and decor are randomized, so there are new connections every time you play. It’s a huge amount of work, but done right, I think it’d be brilliant.