Tiled TMX Loader
Tiled TMX Loader - v.11
Leif Theden (bitcraft)
Map loader for TMX Files
Leif Theden (bitcraft), 2011-2014
v3.19.3 - for python 2.7 and 3.3+
If you have any problems or suggestions, please open an issue on the github page.
I am also often lurking #pygame on freenode. Feel free to contact me.
released under the LGPL v3
PyTMX is a map loader for python/pygame designed for games. It provides smart
tile loading with a fast and efficient storage base. Not only will does it
correctly handle most Tiled object types, it also will load metadata for
them, so you can modify your maps and objects in Tiled, instead of modifying
your source code.
API with many handy functions
Properties metadata for all native Tiled object types
Point data for polygon and polyline objects
Automatic flipping and rotation of tiles
Supports base64, csv, gzip, zlib and uncompressed XML
Image loading with pygame (works ok without pygame)
>>> import pytmx
>>> tmxdata = pytmx.TiledMap("map.tmx")
Load with Pygame Surfaces
>>> from pytmx import load_pygame
>>> tmxdata = load_pygame("map.tmx")
The loader will correctly convert() or convert_alpha() each tile image, so you
don't have to worry about that after you load the map.
Getting the Tile Surface
>>> image = tmx_data.get_tile_image(x, y, layer)
>>> screen.blit(image, position)
Getting Object Properties
>>> tmxdata = TiledMap('level1.tmx')
>>> props = txmdata.get_tile_properties(x, y, layer)
>>> props = tmxdata.get_layer_by_name("dirt").properties
Using Raw XML
It is possible to load TiledMap object from XML strings.
>>> tmxdata = TiledMap.from_string(xml_string)
I have another repo with a working demo of a proper scrolling map using Tiled
maps. Please feel free to test drive it. It isn't limited to Tiled maps,
you can use any data structure you want, as long as PyGame is used.
The 16x16 overworld tiles were created by MrBeast at opengameart.org. CC-BY 3.0
click to view original size
Pygame.org account Comments
If you wish to leave a comment with your pygame.org account, please sign in first.
pygame.org welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
Jul 24, 2016
Jul 17, 2016
Jul 3, 2016
Jul 1, 2016
Jun 19, 2016
Jun 12, 2016
Jun 3, 2016
Jun 1, 2016
May 27, 2016
May 21, 2016