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

Python 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.1.tar.gz (16.4 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.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyglet_ldtk-0.1.1.tar.gz
  • Upload date:
  • Size: 16.4 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.1.tar.gz
Algorithm Hash digest
SHA256 c4ff22f949d64f4b689172f2b50181a3c8873b9a779ca6cfaf94b793f6765278
MD5 23229f642581e58b34fecf52e668af34
BLAKE2b-256 a1ae5e8ec661a6fab619a93723bd54458832d180d983d0add25cfb123764f9f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyglet_ldtk-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pyglet_ldtk-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3868d6ed1d4ce60fe78adb9f96ec30682edcafcea7d45305514d09009ba80626
MD5 defe1a6249783f852d691ed704dfab92
BLAKE2b-256 f553ec00e6fcff73dbbfdacabac4f0216afb5984fc069c3d9f472aefa0a79078

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyglet_ldtk-0.1.1-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