ludic/changes/tiled-maps.md
Orkuncakilkaya b8c71d2a8e
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 21s
ci / build-and-test (push) Successful in 1m57s
commit-lint / conventional-commits (push) Successful in 3s
docs / build-and-deploy (push) Successful in 27s
feat(stdlib): Tiled P4 — objects, custom props/types, templates, opt-in spawn (#72)
- Object layers: all shapes (rectangle/ellipse/point/polygon/polyline/text) and
  custom properties parse and are queryable — Tiled.object_count / Tiled.object /
  Tiled.object_shape, and Tiled.prop / prop_int / prop_type over any object /
  tile / layer / map.
- Custom types: Tiled.load_types reads an objecttypes.xml project custom-type
  table so a class property resolves its default; enum values resolve as strings.
- Templates: Tiled.template reads a .tx/.tj, and Tiled.load merges each object's
  `template` reference under the instance's overrides (field inheritance).
- Opt-in spawning: Tiled.spawn / Tiled.spawn_layer map an object's class +
  properties onto Ludic components through the reflection ABI (Position from x/y,
  each property to a like-named field). Off by default — no gameplay coupling in
  the core load. Split into tiled_spawn.ludic, spliced only for a Tiled *game*
  (the world table exists only under has_ecs), so a plain map-reading tool never
  links against the reflection ABI.

Proven by library/tiled_p4.ludic (18 assertions) incl. the design's named
orthogonal-outside.tmx object shapes. x test: 95 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-01 15:08:06 +03:00

3.3 KiB
Raw Blame History

bump: minor type: feat

Tiled map support (#67–#74) — load and draw Tiled maps (TMX/TSX/TX and TMJ/TSJ/TJ), the design record from #66.

  • P0 parsing primitives (#67) — a minimal pure-Ludic XML reader (Xml.*) for the element/attribute/CDATA subset TMX/TSX/TX use; standard base64 decode/encode (Base64.*, RFC 4648), whose decoder ignores the whitespace Tiled wraps into <data>; and gzip framing (z_gunzip, RFC 1952) wrapping the existing DEFLATE inflater. zlib and the JSON reader already shipped. A curated, attributed golden corpus lands under assets/tiled-fixtures/.
  • P0.5 TMX/TSX reader (#68) — Tiled.read / Tiled.read_tsx map the native XML formats onto the same intermediate the JSON path produces — a Value tree in Tiled's JSON schema, with every tile layer's data decoded to a dense GID list (CSV, base64, base64+zlib, base64+gzip). A CSV .tmx and a base64+zlib .tmj of the same map read structurally identically; the in-repo Kenney sampleMap.tmx + external sampleSheet.tsx load with no manual JSON re-export.
  • P1 core load + render (#69) — the runtime rt_tmap model (heap-allocated to w·h, lifting the old 96×64 cap), the GID resolver (Tiled.resolve → tileset / local id / H·V·D flips), image-backed rendering (Tiled.draw, flips applied at blit), and the legacy-tilemap compatibility projection so Grid.*/Path.*/esys_move keep working. Tiled.load reads either format, resolves external tilesets + images, and auto-projects a collision layer. The Kenney sample loads and renders pixel-identically from .tmx and .tmj; the grid and physics_tiles demos now run off a loaded map.
  • P2 collision & grid (#70) — normalise three collision sources into the byte tilemap esys_move/Grid.*/Path.* read, in the design's priority order: per-tile <objectgroup> hitboxes, the solid/oneway/trigger property convention (Tiled.collision_kind/Tiled.tile_shapes), and the designated collision layer (Tiled.project, any non-zero GID solid) — or drive collision from a visual layer's per-tile metadata alone (Tiled.collide). The property convention and the collision-layer fallback produce the same feed; Path.a_star over a loaded map matches the hand-authored baseline.
  • P3 animated tiles + tile objects (#71) — a tileset <animation> advances deterministically as a pure function of the fixed 60/s engine frame clock (Tiled.frame_gid/Tiled.animated), so an animated GID resolves at draw to the current frame's GID with its flip flags preserved and reproduces frame-for-frame across runs; Tiled.draw_anim draws a map with animations advanced. Object-layer entries with a gid render the tile image (with their own flips), bottom-anchored, as placeable sprites.
  • P4 objects, properties, templates, spawning (#72) — all object shapes (rectangle / ellipse / point / polygon / polyline / text) and custom properties parse and are queryable (Tiled.object, Tiled.object_shape, Tiled.prop/Tiled.prop_int/Tiled.prop_type); class properties resolve their defaults against a project custom-type table (Tiled.load_types over objecttypes.xml); template instances inherit their .tx/.tj template's fields; and an object maps onto Ludic components on demand (Tiled.spawn/Tiled.spawn_layer, off by default, via the reflection ABI).