Skip to main content

A loader for LDtk (Level Designer Toolkit) maps, specifically designed for use with the pyglet game development library.

Project description

pyglet-ldtk

Tests PyPI - License Python Version PyPI - Version Code style: black

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 .ldtk project 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 Batch system 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:

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

pyglet_ldtk-0.1.2.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

pyglet_ldtk-0.1.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file pyglet_ldtk-0.1.2.tar.gz.

File metadata

  • Download URL: pyglet_ldtk-0.1.2.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyglet_ldtk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2568cf1fb588c009ba92cf9627b62da78ec7fb1f2f48a7a00525548b733b5e9f
MD5 2a5be341ef35b5abb5f7339cb82e6636
BLAKE2b-256 73afdb70fb30b98fc1985cd80148a382d051d8acb3e3b3a4e6f2d7c549dd75b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyglet_ldtk-0.1.2.tar.gz:

Publisher: pypi-publish.yml on Kaleidosium/pyglet-ldtk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyglet_ldtk-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyglet_ldtk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyglet_ldtk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b13dbd7d9358a047b05aa45cb14392c4a68886c68db7a41dc89ff797b1c4791
MD5 41c98e13de623c36997216abe3f5b5dc
BLAKE2b-256 5e9685fef76344a4f7c297d8ebbb1922e82762907f3fd00e6368a4de7793aaae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyglet_ldtk-0.1.2-py3-none-any.whl:

Publisher: pypi-publish.yml on Kaleidosium/pyglet-ldtk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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