Reputation: 61
I want to make a survival game, with a as big as possible tile map. I am using the Love2D game engine with lua. Currently I am generating the map with a 2d array. This works well for perhaps a 10x10 tiles map. I want to make them as large as possible. At least 1000x1000-100000x100000. But that juat won work. I also thought about spliting it up in chunks but I have no Idea how. Would I split up theese chunks in other small tilemaps? Or how could I do that? Can anyone help me?
Upvotes: 1
Views: 903
Reputation: 5857
Read a bit about "Space partitioning" in general. Pay attention to BSP/Quadtree/k-D tree, those are building blocks for pretty much anything.
If your chunks are equal in size, positioned in regular grid and has limited overall size, you can simplify everything greatly.
Store chunks in files under names that is composed of chunk indices by x/y axes. Such name would act as chunk's id, and filesystem will work as db storing the world. Some chunks may be missing completely, that means there's nothing in that part of the world.
When you need to show part of the map on screen, you check if you have needed chunks loaded already. You know coordinates of the part you need to show, you build chunk id, check some cache (lua table), and if chunk is not there - try to open the file with same name. If file is loaded successfully - add it to the cache, if not - add empty dummy to signal there's nothing to show.
Upvotes: 1