feat(engine): Tiled P1 — rt_tmap model + GID resolver + render + projection (#69)
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 20s
ci / build-and-test (push) Successful in 1m48s
commit-lint / conventional-commits (push) Successful in 3s
docs / build-and-deploy (push) Successful in 27s

The heart of Tiled support: load a map and draw it.

- rt_tmap model (Tmap/TmLayer/TmTileset in tiled.ludic): map header + ordered
  layers (dense int32 GID arrays, heap-allocated to w*h, lifting the 96x64 cap)
  + tilesets. Built from the intermediate Value tree, so the TMX and TMJ paths
  both feed it.
- GID resolver (Tiled.resolve): gid -> (tileset, localId, flipH/V/D); the three
  flip flags masked off before the local-id lookup, returned alongside. gid==0
  is empty.
- Image-backed render (Tiled.draw): every visible tile layer in file order,
  blitting each tile from its tileset image with flips applied at draw.
- Compatibility projection (Tiled.project / auto on load): a designated
  collision layer projects to the legacy byte tilemap ('#' solid, '=' one-way
  via the oneway property, ' ' empty) so Grid.*/Path.*/esys_move are unchanged.
- Tiled.load resolves external tilesets + images relative to the map file and
  auto-projects a collision/solids/walls layer.
- The grid and physics_tiles demos now run off a loaded map (grid_maze.tmx /
  physics_map.tmx) instead of hand-authored Map.row strings, byte-identically.

Two compiler fixes fell out of this (see the changeset):
- emit_index_addr set g_addr_ty before evaluating the index, so slice[obj.field]
  came back mis-typed; set it last, like the raw-pointer branches.
- @strcmp was declared by both the world table and the fs prelude; centralise
  it in the head prelude so a game that uses Fs/Path links.

Proven by library/tiled_p1.ludic (14 assertions: loads+renders Kenney map
identically from .tmx and .tmj, flip mirroring) + the converted grid/
physics_tiles demos. x test: 92 passed; self-host bootstrap fixpoint intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-01 14:43:29 +03:00
parent 071c268de7
commit bc301c8d17
29 changed files with 12932 additions and 9582 deletions

View file

@ -35,13 +35,13 @@ program PhysicsTiles {
let f_grd = World.field_id(pb, "on_ground")
let f_hw = World.field_id(pb, "hit_wall")
# 16px tiles; '#' (35) is solid, '=' (61) is a one-way platform.
Map.size(16, 10)
Map.row(4, " === ") # one-way platform, cols 10-12 (y 64)
Map.row(5, " # ") # wall column, col 6, rows 5-7
Map.row(6, " # ")
Map.row(7, " # ")
Map.row(8, "################") # solid floor, row 8 (top edge y 128)
# 16px tiles; the map is now a loaded Tiled map (issue #69). Its `collision`
# layer projects to the same byte tilemap: a non-zero GID becomes '#' (35,
# solid), and a GID whose tile carries the bool `oneway` property becomes
# '=' (61), a one-way platform — so esys_move sees the identical grid.
# one-way platform, cols 10-12 (y 64); wall column, col 6, rows 5-7;
# solid floor, row 8 (top edge y 128).
Tiled.load("assets/tiled-fixtures/physics_map.tmx")
spawn Config { Solids { tile: 16, wall: 35, oneway: 61 } }
# ---- T1. fall and land on the tile floor -------------------------------