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, though XML-encoded files can be converted with tmxpy.XMLtoCSV

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.2.2.tar.gz (18.5 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.2.2-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tmxpy-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2f73561e0fd5b4f964435e88b84d09ade750b6bf605d54eaebd7d347e89a3d94
MD5 b3b0f8aee1e23faebcc0c817234f4552
BLAKE2b-256 9a3240882f150582f682eee1825f5d0ac72345ed4bd13f6845adc8ea824e67d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tmxpy-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 18.5 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.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 07c52a2246d83c69191111b702f384244f8bf7e245502c6d92713c9e1ea4c823
MD5 17847a8523d6ad8d867b9a99f5a1cd7c
BLAKE2b-256 86ff8c596d2d23b3df55bce2d7b8dcca6d6769a42fb264df09f20d4943e56228

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