my game's idea is to use a open world map consisting of say 4096x4096 size, and multiple grids of 64x64 size. When I click on any grid, the map zooms in to show that grid(either creating in from scratch or loading off a JSON) because saving all the grids could not be memory efficient. Is there any algorithm to do like this?
1
-
\$\begingroup\$ What did you mean by "saving all the grids could not be memory efficient"? If they're loaded from file, they're already saved. Did you mean that storing all the grids in memory wouldn't be efficient? \$\endgroup\$ – Pikalek Oct 10 '19 at 16:24
Add a comment
|
\$\begingroup\$
\$\endgroup\$
2
You don't really need any specific algorithm to accomplish this. One way you can achieve that is this:
- Make an array that holds your tiles, most likely a 2D array will do.
- For each tile, make a
json
file, that describes what that tile looks like. Name thejson
files in a sequence, so the first tile would betile_0.json
the next onetile_1.json
etc etc. - When the user clicks on a tile, depending on which tile it was, open the right
json
file, and load everything that it needs.
Depending on what language / platform / tools you are using, this might look different in actual code.
-
\$\begingroup\$ But how do i generate the json file? Like filling the contents of the submaps ? \$\endgroup\$ – Avra Neel Oct 10 '19 at 15:18
-
\$\begingroup\$ @AvraNeel That's up to you. Are you using a tool that can export to
json
? Or do you want to do it manually?json
is a very flexible format. \$\endgroup\$ – TomTsagk Oct 10 '19 at 15:24