Skip to main content

A Python library for reading and writing TMX files.

Project description

TMXpy

A Python library for reading and writing TMX files.

This library is fairly computer intensive, especially when rendering large maps. It is recommended to use a computer with decent specs when using this library.

Please note: This library only supports files saved with the CSV encoding.

Features

  • Rendering of TMX files to images
  • Replacing specific warps with other warps
  • Changing tiles of a TMX file
  • Adding tilesets to a TMX file

Installation

pip install tmxpy

Usage and Examples

from tmxpy import TMXpy
from pathlib import Path

tmx = TMXpy(sheets=[Path("path/to/tilesheet/directory")], path=Path("path/to/tmx/file"))
tmx.generateGIDDict()
tmx.renderAllLayers().save("path/to/output/image.png")

tmx.parseWarps()
tmx.replace_warp(0, {
    "map_x": 23,
    "map_y": 17,
    "destination": "Town",
    "dest_x": 10,
    "dest_y": 8,
})

tmx.setTile(23, 17, "129", layerName="Buildings")

Further examples can be found in the tests directory.

Development/Testing

  • Install dependencies with pip install -r requirements.txt
  • Tests can be added to tests/name_of_test.py and run with py -m tests.name_of_test
  • It can be built with py -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tmxpy-0.1.7.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tmxpy-0.1.7-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file tmxpy-0.1.7.tar.gz.

File metadata

  • Download URL: tmxpy-0.1.7.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for tmxpy-0.1.7.tar.gz
Algorithm Hash digest
SHA256 51ca8477b6beec25fcd2ddac26086069a14ef34a14028abe5ec503b5c56698c3
MD5 fe6e1111dfb115e7a1ba5f7b57544040
BLAKE2b-256 de1134f9f2c45f17251200dad77de866a4fec537312a1a8d10a14cfa5404da05

See more details on using hashes here.

File details

Details for the file tmxpy-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: tmxpy-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for tmxpy-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 28561182feb79d2f68b34fa3c350a645fb3c9c2917148db180fea1da9b2983db
MD5 f1920ea753def35e3e41dd1406b0b660
BLAKE2b-256 52c6de44066e67e2cff31892eff2e279272a193200031c031d2cca54db590201

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page