I'm trying to create an arbitrary sized(but not infinite) 2d tilebased world. My question is, how do i save a world like this?

My idea was to split up the tiles into bigger chunks and then save those seperately. Let's say you have a world of 5000x5000 tiles, each chunk would be 50x50 and saved in a seperate file. This leaves me with 10000 seperate files, which does not seem optimal. Is there a better way?


1 Answer 1


This is usually ideal - you can also further decide to split things into 'regions'. This is pretty similar to how Minecraft does things and you can probably learn a lot from just examining it. Splitting it into multiple file sis ideal because while it does incur a penalty for opening the file still, it makes things manageable and prevents large seeking times on a single large file on slower drives. You can read up on this post here for more information on the method. Essentially, what you had in mind is a good idea - just try and minimize chunks into optimal amounts. Good luck!

  • \$\begingroup\$ What are adventages of many-files approach versus NoSQL database? \$\endgroup\$
    – szotp
    Feb 2, 2013 at 16:35
  • \$\begingroup\$ This is basically what i thought too, but it still gives me lots and lots of small files, while minecraft only has one level.dat file. How is that done? \$\endgroup\$
    – ThatOneGuy
    Feb 2, 2013 at 16:53
  • 1
    \$\begingroup\$ Level.dat is just an index. Read up on the file format and check out the open source InfiniMiner \$\endgroup\$ Feb 2, 2013 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .