1
\$\begingroup\$

I have a 2D map of 500 x 500 tiles, split into chunks of 256 x 256.

I'm saving each chunk as a separate file, and I have them loading in as the player moves around. This means however there's over 1024 chunk files currently- and more to come when I increase the map.

Is this normal practice? I have no stutters when the game streams map loads or anything.

\$\endgroup\$
  • \$\begingroup\$ That's a huge map, 25 million tiles... If you haven't already, you're going to see file system slowdowns when dealing with thousands of individual files inside a directory structure. For reference, a really big JRPG style 2D map is only 500x500 and most world maps are only 200x200. It's possible you've made each tile too small, if you double the dimensions of each tile that will shrink the total count by 4, etc... \$\endgroup\$ – Patrick Hughes Feb 11 at 20:54
  • \$\begingroup\$ If you have no problems with it then it's fine. If loading works as I think it should - load files directly by path without any additional checking - then it's probably the best way as it is right now. Because you have instant loading of small chunks. \$\endgroup\$ – Candid Moon _Max_ Feb 11 at 20:55
  • \$\begingroup\$ @PatrickHughes if it's open world then there is no choice really but to have this big map somewhere on the disk. Loading bigger chunks may not be an option if there are many objects and RAM can't have all of them at once. Loading big chunks may be slower. Probably the best way is to have some kind of system like Database and index chunks, load them fast. But doesn't file system work the same way? It's the only thing that comes to my mind, it would be great if there is a better way. But this is as far as my knowledge of this goes right now. \$\endgroup\$ – Candid Moon _Max_ Feb 11 at 21:02
  • \$\begingroup\$ What platform are you targeting? Assuming a 2-byte short for each tile lookup that's then only 500K RAM for your entire map. Then you just need a smart cache for your actual tile graphics. \$\endgroup\$ – Patrick Hughes Feb 11 at 21:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.