0
\$\begingroup\$

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?

\$\endgroup\$
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\$ Commented Oct 10, 2019 at 16:24

1 Answer 1

1
\$\begingroup\$

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 the json files in a sequence, so the first tile would be tile_0.json the next one tile_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.

\$\endgroup\$
2
  • \$\begingroup\$ But how do i generate the json file? Like filling the contents of the submaps ? \$\endgroup\$ Commented Oct 10, 2019 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\$ Commented Oct 10, 2019 at 15:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.