Map format?

258 views
Skip to first unread message

mojoe

unread,
Nov 12, 2011, 11:57:41 AM11/12/11
to Tiled Map Editor
Is there somewhere that explains exactly how the tmx file is
generated? I have a 32x32 tileset, so 1024 tiles. I can clearly see
that the file format is writing out an indexer into the tileset image,
but at some tiles I get numbers that do not fall into those ranges.
For example here are a few that I get back on my map.

<tile gid="1073741985"/>
<tile gid="1073741986"/>
<tile gid="1073741987"/>
<tile gid="1073741988"/>
<tile gid="1073741989"/>
<tile gid="1073741990"/>
<tile gid="1073741991"/>

I'm assuming this is because some type of bitwise operation is
occurring to determine some types of information such as flipping,
collision details, etc...?

Is there a document somewhere that describes exactly what all of these
are? I've searched the website; mailing list, and I'm coming up empty.

Petr Viktorin

unread,
Nov 12, 2011, 12:23:24 PM11/12/11
to mape...@googlegroups.com
Hello,
The documentation is at https://github.com/bjorn/tiled/wiki/TMX-Map-Format.

You were correct, information about flipped tiles is stored in the
upper bits of the "gid". Horizontal flip is 0x80000000 and vertical
flip is 0x40000000.

The next Tiled release will support rotation; for this the 0x20000000
bit will represent transpose (flipping the x/y axes).

Hope that helps,
Petr Viktorin

> --
> Tiled Map Editor mailing list
> mape...@googlegroups.com
> http://groups.google.com/group/mapeditor
>

mojoe

unread,
Nov 12, 2011, 1:52:09 PM11/12/11
to Tiled Map Editor
Thanks; very helpful. I see now that it is linked to from the wiki,
but I missed it :(

Curious; is there a way to write the values to hex rather than base10?

On Nov 12, 11:23 am, Petr Viktorin <encu...@gmail.com> wrote:
> Hello,
> The documentation is athttps://github.com/bjorn/tiled/wiki/TMX-Map-Format.

Thorbjørn Lindeijer

unread,
Nov 12, 2011, 3:38:54 PM11/12/11
to mape...@googlegroups.com
On Sat, Nov 12, 2011 at 19:52, mojoe <joiey....@gmail.com> wrote:
> Thanks; very helpful.  I see now that it is linked to from the wiki,
> but I missed it :(
>
> Curious; is there a way to write the values to hex rather than base10?

There is no way to choose hex rather than base10. Why would you want to do so?

>> On Sat, Nov 12, 2011 at 18:57, mojoe <joiey.see...@gmail.com> wrote:
>> >  <tile gid="1073741985"/>
>> >   <tile gid="1073741986"/>
>> >   <tile gid="1073741987"/>
>> >   <tile gid="1073741988"/>
>> >   <tile gid="1073741989"/>
>> >   <tile gid="1073741990"/>
>> >   <tile gid="1073741991"/>

I'd like to point out that this is the least space-efficient and
slowest method of storing the tile layer data. I'd recommend against
using pure XML and choose CSV when you need readability (but that
doesn't hold when flipping anyway) or binary (base64-encoded) layer
data for smaller files that are faster to load.

I'm considering to deprecate the above format since it's a bit of a trap.

Best regards,
Bjørn

Joe Seeley

unread,
Nov 12, 2011, 3:58:57 PM11/12/11
to mape...@googlegroups.com

I'm not planning to use any of the tmx formats anyway. I'm creating a parser that will write them to a different file format for my game engine.

Pelle Nilsson

unread,
Nov 12, 2011, 5:16:18 PM11/12/11
to mape...@googlegroups.com
Hi,

On Sat, Nov 12, 2011 at 6:23 PM, Petr Viktorin <enc...@gmail.com> wrote:
> Hello,
> The documentation is at https://github.com/bjorn/tiled/wiki/TMX-Map-Format.
>
> You were correct, information about flipped tiles is stored in the
> upper bits of the "gid". Horizontal flip is 0x80000000 and vertical
> flip is 0x40000000.
>
> The next Tiled release will support rotation; for this the 0x20000000
> bit will represent transpose (flipping the x/y axes).
>

Please remember hex tiles when adding rotation. :)
--
/Pelle

mojoe

unread,
Nov 12, 2011, 8:23:58 PM11/12/11
to Tiled Map Editor
Saw the response on my phone earlier and didn't notice your first
question about "why hex rather than base 10". Sometimes I'm opening
the file directly in a program like Notepad++ or Vim to see what is
going on. In this case the hex value really jumps out and says what's
going on. I would see then something like 0x80000123 or 0x40000789
and immediately I say; ah that first tile is flipped horizontally and
indexes to tile #123 and that second one is flipped vertically and
indexes to tile #789.

That same thing in decimal looks like 2147483939 and 1073743753.
Right away I thought to my self; there is some bitwise operation going
on here, but then I'm going to have to break out my calculator etc...
So this is really just more of a; oh that would be convenient thing;
not really a "needed" feature.

const unsigned FLIPPED_HORIZONTALLY_FLAG = 0x80000000;
const unsigned FLIPPED_VERTICALLY_FLAG = 0x40000000;

On Nov 12, 2:38 pm, Thorbjørn Lindeijer <thorbj...@lindeijer.nl>
wrote:

Thorbjørn Lindeijer

unread,
Nov 13, 2011, 5:47:14 AM11/13/11
to mape...@googlegroups.com

Unfortunately the rotation won't work for hex tiles, since as Petr
pointed out they are implementing using a bit to indicate a swap of
the x and y axes.

Regards,
Bjørn

Pelle Nilsson

unread,
Nov 22, 2011, 5:58:38 PM11/22/11
to mape...@googlegroups.com
Hi,

2011/11/13 Thorbjørn Lindeijer <thor...@lindeijer.nl>:

I guess that the bits used for rotation mirroring on rectangular (and
iso?) tiles can be used differently for hexagon tiles without causing
any conflicts in the file format? But to get all the possible
rotations/mirrorings of hexagons you might need 3 or 4 bits.

--
/Pelle

Reply all
Reply to author
Forward
0 new messages