Tiled2GM —  download Tiled2GM Converter (2,5mb)

Tiled map loader


While developing our game Journey to Hammerdale we have faced a problem of built-in Game Maker level edtior to be very limited in it's abilities, thus began to search for alternatives. We needed a very simple and handy map editor that would support multiple layers (and manipulations over them). A matching one was found quite fast — Tiled Map Editor. It's capabilities were fully covering our needs and so a loader for ones map format was done in Game Maker.

Apart from actual tiles, Tiled allows to place object, and assign properties to objects and layers around the map. Support for this functionality was also added to loader. For example, in map properties level name and background color were defined. In object properties — instance-specific variables like saw's movement speed. Support for horizontal and vertical mirroring of tiles was also added in, along with layer transparency.


Usage.

Converter use .NET Framework 4.0. TiledLoader need Game Maker 8.1.

Process is simple, though still requires a couple of actions.

First you need to draw your map in Tiled. Map can be of any size, and contain any number of objects and/or layers. Also you can add custom properties to map, layers, and objects (property handling is described below).

Then launch Tiled2GMConverter, and select your map in it. File will be processed and saved as a .lvl.

The last thing to do is to open TiledLoader in Game Maker and configure it — add your objects, and if needed, property handlers.

Map loading is done from Create event of object o_controller.

load_room('loader_demo.lvl')

here you specify filename, in which map is saved.

 In script define_objects you need to setup your objects (with same order as in objects-tileset). Un-recognized objects will be displayed as special object type o_not_defined, which looks like a black circle with red-cross in the middle.

 Script check_property does handling of map and layer properties. As an example, map property bgcolor is handled, which defines background color, and name, which defines window title. For layers, depth property is handled, which defines depth (draw order) for layer. If depth of layer is not defined, it is set to 10000.

 View properties can be configured in the end of load_room script, via command room_set_view.

Property handling of object properties is done in Create event of objects. As an example, a single property is handled for o_skeleton and several properties are handled for o_doctor.

Important: Tileset images must be placed in tilesets folder, while loaded maps must be placed in maps folder.

 Cursor control keys can be used for scrolling map in the example.


Limitations.

At the moment there are several limitations for files, that are processed by converter:

  • Data encoding must be set to base64 (can be set in Tiled properties)

 

  • Objects must be drawn via 'object tile' instrument — other types of objects are not supported.

  • Names of tileset files must be defined inside of map, rather than separate file (this may occur if external tileset is defined in editor)

 Example:
<tileset firstgid="1" source="objects.tsx" />
<tileset firstgid="626" name="tileset99999" tilewidth="32" tileheight="32">
<image source="tileset99999.png" width="800" height="800" />
</tileset>

 here the line 
<tileset firstgid="1" source="objects.tsx" />
 points to external file, in which tileset properties are defined:
<tileset name="objects" tilewidth="32" tileheight="32">
<image source="objects.png" width="800" height="800" />
</tileset>

At the moment converter cannot handle such external files, so data from external file must be added in like this:
<tileset firstgid="626" name="tileset99999" tilewidth="32" tileheight="32">
<image source="tileset99999.png" width="800" height="800" />
</tileset>

 For this example, resulting code will be:
<tileset firstgid="1" name="objects" tilewidth="32" tileheight="32">
<image source="objects.png" width="800" height="800" />
</tileset>

  • Tile rotation (+- 90 degrees) is not supported.

Contact.

If you have found an error, or have suggestions, send me a message. Use contact form (select Dmi7ry)
 


Links.

http://www.mapeditor.org  —  Tiled map editor.
http://j2h.ru  —  Devlog of our game "Journey To Hammerdale".
Tiled2GM  —  download Tiled2GM Converter (rar, 2,5mb)
Tiled2GM  —  download Tiled2GM Converter (zip, 2,5mb)