pyglet-ldtk
A loader for LDtk (Level Designer Toolkit) maps, specifically designed for use with the pyglet game development library. This module simplifies the process of integrating your LDtk level designs into your pyglet applications, handling everything from parsing LDtk JSON files to rendering complex tile layers and entities.
Features
- LDtk Project Loading: Parses standard
.ldtkproject files and supports external level files. - Tileset Management: Loads tileset images, extracts tile regions, and handles tile flipping.
- Entity Rendering: Renders LDtk entities, including support for basic shapes, custom tile textures, and advanced 9-slice scaling.
- Layer Handling: Processes various LDtk layer types: IntGrid, Entities, Tiles, and AutoLayers.
- Coordinate System Conversion: Automatically converts LDtk's top-left origin coordinates to pyglet's bottom-left origin.
- Batch Rendering: Optimized for pyglet's
Batchsystem for efficient rendering. - IntGrid Visualization: Renders IntGrid layers as colored rectangles for easy debugging or visualization.
Installation
pip install pyglet-ldtk
Usage
(For detailed usage examples, please refer to the tests/ directory for now. A more comprehensive guide will be added here eventually.)
import pyglet
from ldtk import Ldtk
# Load your LDtk project
ldtk_project = Ldtk("path/to/your/project.ldtk")
# Get the first level
level = ldtk_project.levels[0]
# Create a pyglet batch
batch = pyglet.graphics.Batch()
# Add the level's content to the batch
level.addToBatch(batch)
# Basic window setup (example)
window = pyglet.window.Window(level.sizePx[0], level.sizePx[1], caption="LDtk Level")
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.app.run()
Compatibility
- Python 3.10+
- Pyglet 2.1.11+
Acknowledgment
This repository would not be possible without the following prior art:
Metadata
Release files for pyglet-ldtk 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyglet_ldtk-0.1.2.tar.gz | 16.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyglet_ldtk-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.9 kB
Release files / pyglet_ldtk-0.1.2.tar.gz
| Download URL | pyglet_ldtk-0.1.2.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2568cf1fb588c009ba92cf9627b62da78ec7fb1f2f48a7a00525548b733b5e9f
|
|
BLAKE2b-256 checksum How to use checksums |
73afdb70fb30b98fc1985cd80148a382d051d8acb3e3b3a4e6f2d7c549dd75b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2025.
Transparency logRelease files / pyglet_ldtk-0.1.2-py3-none-any.whl
| Download URL | pyglet_ldtk-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b13dbd7d9358a047b05aa45cb14392c4a68886c68db7a41dc89ff797b1c4791
|
|
BLAKE2b-256 checksum How to use checksums |
5e9685fef76344a4f7c297d8ebbb1922e82762907f3fd00e6368a4de7793aaae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2025.
Transparency log