How to create a over world map with multiple sub maps

by Avra Neel   Last Updated October 10, 2019 15:13 PM

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?

Answers 1

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.

October 10, 2019 15:05 PM

Related Questions

Updated November 18, 2017 06:13 AM

Updated January 16, 2019 01:13 AM

Updated September 25, 2017 19:13 PM

Updated July 30, 2018 17:13 PM

Updated December 13, 2018 10:13 AM