I'm making a map editor for my game and I'm at the point where I need to save the map to a file. My Maps contain multiple layers though, which will be stacked on eachother for display. I know I could save each file seperately but I wanted these to be contained in a single file.

Is there an easy way to do this that I'm not thinking about? TIA

XMLEncode and XMLDecode will convert anything bean-like to XML dead easily. Also works for beans-within-beans, so you can encode/decode an entire List, or arbitrary top-level container object in just one method call.

You could also create a zip file with all your files in it (java.util.zip.*)

Edited 1 Year Ago by JamesCherrill

"Real" game maps are almost always stored as binary to reduce load time and to prevent easy editing using a text editor (some sort of obfuscation).


Also, if you have got simplistic sort of data you can use existing binary formats like protocol buffer for encoding your data.


The obvious disadvantage being requiring more work and not being human readable. It really depends though, go with XML/JSON if you are not going to have crazy big maps...

If you want to have fun with "from scratch development", try implementing binary maps, if not, just go with the simplest possible XML representation.

Edited 1 Year Ago by ~s.o.s~

This article has been dead for over six months. Start a new discussion instead.