views:

51

answers:

3

I'm trying to figure out how I can best save the map data for a 2d ORPG engine I am developing, the file would contain tile data (Is it blocked, what actual graphics would it use, and various other properties).

I am currently using a binary format but I think this might be a bit too limited and hard to debug, what alternatives are there, I was thinking about perhaps JSON or XML but I don't know if there are any other better options.

It has to work with C++ and C# and preferably also with Python.

A: 

Lua is also a possibility which can be used as a config file with tables. It's been a while since I worked with Python but doesn't it also support a AJAX style data structure? You could simply use Python files if you are already using it.

Nick
"It has to work with C++ and C#, and preferably also python". and AJAX style data structures would be JSON I think. And I rather not use a programming language-esque thing to save the data in.
Xeross
+1  A: 

XML is well supported across basically every language. It may become verbose for large maps, however, depending on how you encode the map data in XML.

JSON might not be a good choice, simply because I don't think it supports multiline strings, which would be helpful (although not really necessary)

YAML is another alternative, though it's not as well-known.

You could just stick to binary - most maps would be a pain to edit by hand, no matter what format you pick (though I've heard of Starcraft maps being edited with hex editors...) Just use whatever seems easiest for you.

Additionally, check out the Tiled map editor (http://www.mapeditor.org/), which lets you edit maps (with custom tile properties, I think) and save it in an XML based format, including optional GZip for compression.

l33tnerd
Hmm it doesn't require multiline strings, and I think json does support them though. Also I've used YAML before and it might be interesting to use
Xeross
+1  A: 

Personally, I would stick with a binary format. Whatever method you choose, it's going to be a pain in the ass to edit by hand anyway, so you may as well stick to binary which gives you a size and speed advantage.

You're also going to want a map editor anyway so that you do not have to edit it by hand.

Moo-Juice
That is indeed good reasoning, however what about things such as a door that requires a key (Would need to store key ID in map), should I save that separately from the actual map data ?
Xeross