Search code examples
dictionaryencodingbase64editortiled

How does base64 encoding work in Tiled map editor


I am using the Tiled map editor for my game that I program in C++ and after I implemented loading methods for my levels using the raw XML .tmx file (no base64 and no zlib compression) I wanted to now do it with base64.

Here comes my problem/question: How does the Tiled map editor converts a data structure like this:

<tile gid="25"/>
<tile gid="25"/>
<tile gid="25"/>
<tile gid="25"/>
<tile gid="25"/>

to a base64 encoded string like this:

GQAAABkAAAAZAAAAGQAAABkAAAA=

?

I think I need to understand that in order to implement the laoding methods for this. I am wondering how to know where the ID of another tile starts and why the encoded string does not match the one I get when I copy my IDs over to https://www.base64encode.org/.


Solution

  • The base64 encoded version of the data is an array of unsigned 32-bit integers in little-endian byte order, each representing a "gid" of a tile. You can find more information about how to process this data on the TMX Map Format page.