World#

This module provides an implementation for the World files from Tiled.

See Tiled’s docs for Worlds for more info about worlds and what they do.

The functionality within PyTiled Parser is to load the world and outline the size and position of each map, and provide the path to the map file. Loading a world does not automatically load each map within the world, this is so that the game or engine implementation can decide how to handle map loading.

WorldMap#

class pytiled_parser.world.WorldMap(map_file: Path, size: Size, coordinates: OrderedPair)#

Represents a map within a world.

This object can be accessed to load in a map after loading the world.

This class translates to each object within the maps list of a World file

map_file#

A Path object to the map file, can be passed to the pytiled_parser.parse_map function later.

Type:

pathlib.Path

size#

The size of the map in pixels

Type:

pytiled_parser.common_types.Size

coordinates#

The position of the map within the world in pixels

Type:

pytiled_parser.common_types.OrderedPair

World#

class pytiled_parser.world.World(maps: List[WorldMap], only_show_adjacent: bool = False)#

Represents a world file.

maps#

The list of maps within the world. These are not fully parsed TiledMap objects, but rather WorldMap objects which can be used to later parse each individual map.

Type:

List[pytiled_parser.world.WorldMap]

only_show_adjacent#

Largely only used by the Tiled editor to determine if only maps adjacent to the active one should be displayed. This could be used to determine implementation behavior as well though to toggle auto-loading of adjacent maps or something of the sort.

Type:

bool