gale.tilemap.tiled_loader module

This file contains the implementation of load_tiled_map: builds a TileMap from a map exported by Tiled (https://www.mapeditor.org/) as JSON (File > Export As… > JSON map files, or Ctrl+Shift+E) — not the XML .tmx format.

Author: Alejandro Mujica (aledrums@gmail.com)

exception gale.tilemap.tiled_loader.TiledLoadError[source]

Bases: Exception

Raised when a Tiled JSON export uses a feature load_tiled_map doesn’t support.

class gale.tilemap.tiled_loader.TiledObject(name, type, x, y, width, height, properties=<factory>)[source]

Bases: object

One entry from a Tiled object layer (a spawn point, a trigger, a checkpoint…) — plain data. What each one means, and what to do with it, is entirely up to the game; load_tiled_map never interprets name/type itself.

Parameters:
  • name (str)

  • type (str)

  • x (float)

  • y (float)

  • width (float)

  • height (float)

  • properties (Dict[str, Any])

name: str
type: str
x: float
y: float
width: float
height: float
properties: Dict[str, Any]
gale.tilemap.tiled_loader.load_tiled_map(path)[source]
Parameters:

path (str) – Path to a map exported by Tiled as JSON.

Returns:

A TileMap with every tile layer, tileset, and object layer the export contains.

Raises:

TiledLoadError – If the map is infinite, or uses a tile layer/tileset encoding this loader doesn’t support (compressed tile data, or a tileset referenced in the old XML .tsx format).

Return type:

TileMap