Skip to main content

Standalone parser/loader for tilemap-editor JSON maps and sprite animation JSON.

Project description

tilemap-parser

Standalone parser/loader package for map JSON produced by tilemap-editor plus sprite animation JSON.

Install

pip install -e .

Load map + inspect layers

from tilemap_parser import load_map

data = load_map("assets/maps/level_1.json")

layers = data.get_layers(sort_by_zindex=True)
for layer in layers:
    print(layer.id, layer.name, layer.layer_type, layer.z_index, layer.properties)

Tile image fetch API (variant + tileset)

tile_surface = data.get_image(variant=12, ttype=0)
tile_surface2 = data.get_tile_surface(0, 12)
cell_surface = data.get_tile_surface_at("Ground", 10, 4)

Raw payload access for debugging

raw = data.get_raw()

get_raw() returns a deep-copied complete parsed root payload (including editor/project fields), so callers can inspect everything safely.

Animation loading + playback helper

from tilemap_parser import SpriteAnimationSet, AnimationPlayer

anim_set = SpriteAnimationSet.load("assets/anims/hero.anim.json")
player = AnimationPlayer(anim_set, "idle")

player.update(16.67)
frame_surface = player.get_current_image()

Optional renderer for tile layers

import pygame
from tilemap_parser import TileLayerRenderer, load_map

data = load_map("assets/maps/level_1.json")
renderer = TileLayerRenderer(data)
renderer.warm_cache()

screen = pygame.display.set_mode((1280, 720))
stats = renderer.render(screen, camera_xy=(camera_x, camera_y))

The renderer pre-indexes tile layers as dict[layer_id, layer], sorts by z_index, ignores object layers, and caches (tileset, variant) cell surfaces to reduce repeated subsurface extraction.

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

tilemap_parser-2.0.1.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

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

tilemap_parser-2.0.1-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file tilemap_parser-2.0.1.tar.gz.

File metadata

  • Download URL: tilemap_parser-2.0.1.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for tilemap_parser-2.0.1.tar.gz
Algorithm Hash digest
SHA256 c35f12cd22d8c8512d3ede26985ffefdf2ff410db570210d28d056a4dbf81282
MD5 8c71f2486f4ca3e7342cdd71d7c4b1b3
BLAKE2b-256 b9bae776424f1e6c224d710638fd2bbb4836953b5f1d86983f1d6f4d123cd1e1

See more details on using hashes here.

File details

Details for the file tilemap_parser-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: tilemap_parser-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for tilemap_parser-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7921a74e95fc0ffec6a601272d8a5cdf9b19e9b0b78395064e0bfaf87f983682
MD5 4055df78d4648d598a00526e042310bd
BLAKE2b-256 374f1f9a217d4e34addec2315a67c9fd2a7155b4acebc427b270ab78104337e9

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