Skip to content

feat: convert tiled maps to the collision contract - #96

Merged
arudaev merged 2 commits into
mainfrom
chore/92-tiled-collision
Oct 23, 2026
Merged

arudaev merged 2 commits into
mainfrom
chore/92-tiled-collision

Conversation

@Vatsal2005

@Vatsal2005 Vatsal2005 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Convert a finite orthogonal Tiled JSON map into the docs/13 collision schema so Lex can draw collision over the stage instead of editing coordinate arrays. All eleven object layers map to the existing contract. Reference image layers are ignored; no art files were generated or changed in this PR.

Issue

Closes #92

Acceptance criteria

  • python scripts/collision_from_tiled.py <export.tmj> writes art/stages/<region>/<chunk>.<state>.collision.json
  • Supports walk, slide, one-way, ledge, climb, solid, no-go, hazard, interact, spawn, glide-lift
  • Rejects unknown collision layers, open/degenerate boxes, out-of-bounds points; also rejects rotated shapes, fractional/non-finite pixels, duplicate IDs and invalid metadata
  • Hand-authored Tiled fixture and CLI tests

Verification

  • py -3.13 -m unittest discover -s scripts -p "test_*.py" — 30 tests pass, including 14 converter tests
  • py -3.13 scripts/check_docs.py — 382 files pass
  • git diff --cached --check
  • CLI test copies the script into a temporary repository root, writes the expected path, and verifies a malformed layer exits 1 with a useful error
  • Invalid input leaves existing output intact
  • Compatibility against all six collision files from PR feat: add Rusty Creek collision with a reach checker #97 at d02f76800704cf88945e4c78b8c260e804e4d214: authored JSON → synthesized Tiled 1.12 JSON → this converter reproduces every field and value exactly. Custom pickup item, spawn patrol, and trigger note metadata are retained. Typed list entries are decoded to plain arrays; custom properties cannot override geometry.
  • Real Tiled UI export and runtime debug-overlay comparison — feat: add Rusty Creek collision with a reach checker #97 currently provides hand-authored collision JSON, no .tmj; runtime overlay belongs to [M1-S6] Load collision annotation per chunk, with a debug overlay #34

Game files are unchanged and the scaffold is still pending in #94, so there is no game build on this independent branch.

Authoring setup / question

The existing collision schema stays unchanged. Destination metadata was unspecified: this implementation reads string map properties region, chunk, state. Example: rusty-creek, rc-0-0, anomaly. Is that acceptable for Lex's Tiled files? The CLI help documents this setup. kind, id, and hazard damage are object properties; an object's name can supply its ID. Box layers use Tiled rectangles, not polygons or polylines. Image layers can show the composed stage as a backdrop. Other object custom properties are preserved. Lists use Tiled 1.12 typed list properties, e.g. a patrol list containing two integer items. No implicit JSON-string parsing is performed.

Screenshots

No visible game change. Real overlay evidence remains pending the annotation and #34.

Give collision authors a deterministic export for all docs/13 layer shapes, using stage pixels and explicit region, chunk and state metadata.

Reject malformed geometry before writing output and cover the conversion, CLI, bounds and existing-output preservation with tests.
@github-actions github-actions Bot added the area:pipeline Rerunnable art and export scripts label Oct 23, 2026
@Vatsal2005
Vatsal2005 marked this pull request as ready for review October 23, 2026 19:35
Rusty Creek annotations now carry pickup item names, patrol bounds and trigger notes. Preserve these custom values instead of silently discarding them during conversion.

Decode Tiled 1.12 typed lists to plain arrays and reject custom properties that would override authored geometry. Add regression coverage for both behaviours.
@arudaev

arudaev commented Oct 23, 2026

Copy link
Copy Markdown
Member

Lane A answers (Alexander + Claude).

  1. Map properties region, chunk, state: accepted. Lex has left the team, so collision is now authored in lane A, and this setup works for us. Chunk ids are grid positions (rc-0-0, hg-0-0). Each region's chunks.json (feat: add Rusty Creek collision with a reach checker #97) maps them to the art, so region is the folder name under art/stages/.
  2. Round-trip check against feat: add Rusty Creek collision with a reach checker #97: thank you. That's exactly the compatibility we need. item, patrol and note are deliberate additive fields, as the docs/13 contract allows.
  3. The unchecked "real Tiled export" box is fine. feat: add Rusty Creek collision with a reach checker #97 and [3/4] feat: add the Hidden Garden collision and Dexter's waypoints #106 were written directly as JSON, and the next region's collision will go through Tiled and this converter.

No changes needed here. It's ready for Alexander to merge.

@arudaev
arudaev self-requested a review October 23, 2026 20:30
@arudaev
arudaev merged commit 7033e22 into main Oct 23, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:pipeline Rerunnable art and export scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[M1-S10] Convert Tiled collision layers into collision.json

2 participants