-3
\$\begingroup\$

I just created a map in tiled software. The problem is that it has created a .tmx file. But I need a different format than that, something I can easily store in 2D int array.

By 2D int array I mean:

0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 2 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1

0 = sky
1 = ground
2 = tree

How do I go about converting the .tmx file into this format?

\$\endgroup\$
2

1 Answer 1

1
\$\begingroup\$

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:

  1. Read the current format
  2. Process the data read into some intermediate state
  3. 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.

\$\endgroup\$
6
  • \$\begingroup\$ ah ok i see so i need to create a rules.txt file which will have all the rules to format the xml file. i tried looking at documentation but had hard time understanding it. is there examples online? \$\endgroup\$
    – dan
    Oct 16, 2013 at 8:21
  • \$\begingroup\$ Examples of what? You have the only example you need with the file you've created. \$\endgroup\$
    – House
    Oct 16, 2013 at 13:14
  • \$\begingroup\$ I am new to game programming and i have no idea what you guys are saying. can some one plz just help me out. what do i put in rules.txt file? \$\endgroup\$
    – dan
    Oct 16, 2013 at 18:17
  • \$\begingroup\$ There's no rules.txt file. The misunderstanding goes both ways. You might want to learn a bit more about programming in general before continuing. Then, I suggest you try a more discussion oriented site if you're having trouble understanding. This site isn't really for discussions. See the bottom of this page for more details on where to ask. \$\endgroup\$
    – House
    Oct 16, 2013 at 18:40
  • \$\begingroup\$ ok got it. but before i leave, just answer me this. do i need to download another software to convert tmx file to 2d int array format? \$\endgroup\$
    – dan
    Oct 16, 2013 at 19:05

You must log in to answer this question.

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