Converting a file from one format to another isn't too hard if you have decent documentation on both formats (or you're making up your own target format). Luckily, Tiled has some software that is available for it that allows you to easily read .tmx files. To convert, follow these basic steps:
- Read the current format
- Process the data read into some intermediate state
- Write the intermediate state into the new format
You can skip step 2 if you don't need to do any rearranging or complex changes and just write directly to the new format from the current format.
First you'll want to learn more about the existing format, so you know what you're reading. Then make a set of rules for converting the existing format into your new format. For example, when you see a land tile, you'll write a 1
to your new file.
It's sometimes a tedious process. You may want to explore your rationale for converting the files in the first place. .tmx files are widely supported, and you might want to stick with that standard and choose a different data structure than a int
array for storing your map.