I'm no expert on this (by any means), but I suppose you could dedicate x bytes at the beginning of the file to define x and y lengths, and then store data sequentially. Like if you have a 5x5 Minecraft-ish world, that looks like this (d=dirt, c=coal, i=iron, g=gold):
ddddd
dcddc
iidgc
ggidd
gggdd
You could define it as "55ddddddcddciidgcggiddgggdd"
I doubt that this technique is very efficient (I came up with it myself
), but AFAICT it will work, as long as your program that reads this can interpret it correctly and has the contents (in this example, d, c, i, and g) defined (possibly hard-coded?). AFAICT this could also be applied for a 3D environment... Although I'm almost sure there are better solutions... Please correct me if I'm wrong in any of this.