feat(engine): Tiled P3 — animated tiles (deterministic frame clock) + tile objects (#71)
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 21s
ci / build-and-test (push) Successful in 1m53s
commit-lint / conventional-commits (push) Successful in 3s
docs / build-and-deploy (push) Successful in 28s

- Animated tiles: a tileset <animation>'s {tileid, duration} frames advance as a
  pure function of the fixed 60/s engine frame counter (the same clock SpriteAnim
  rides), so an animated GID resolves at draw to the current frame's GID with its
  flip flags preserved — deterministic, frame-identical across runs, ticks for
  free. Tiled.frame_gid(map, gid, frame) / Tiled.animated(map, gid) expose it;
  Tiled.draw_anim(map, camx, camy, frame) draws a map with animations advanced.
- Tile objects: object-layer entries with a `gid` draw the tile image (with their
  own flip flags), bottom-anchored at the object position, as placeable sprites;
  tmap_draw_full now renders object layers alongside tile layers.

Proven by library/tiled_p3.ludic (14 assertions): frame advance at authored
durations + wrap, flip flags riding an animation swap, tile-object parse + draw +
flip mirroring, and the design's named rpg/beach_tileset.tsx (33 <animation>
blocks / 131 frames). x test: 94 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-01 14:58:21 +03:00
parent 0cb57774d7
commit 58e1105f2d
13 changed files with 6129 additions and 5312 deletions

View file

@ -0,0 +1,14 @@
---
id: tiled-animated
name: Tiled.animated
category: tiled
kind: namespace-method
tokens: Tiled.animated
sig: Tiled.animated(map, gid: int) -> int
tip: Whether a GID's tile is animated.
order: 19
ns: Tiled
member: animated
---
Returns <code>1</code> if the tile a GID resolves to carries a non-empty <code>&lt;animation&gt;</code>, else <code>0</code>.

View file

@ -0,0 +1,14 @@
---
id: tiled-draw_anim
name: Tiled.draw_anim
category: tiled
kind: namespace-method
tokens: Tiled.draw_anim
sig: Tiled.draw_anim(map, camx: int, camy: int, frame: int) -> void
tip: Draw with animated tiles advanced to a frame.
order: 17
ns: Tiled
member: draw_anim
---
Like <a href="tiled-draw"><code>Tiled.draw</code></a>, but animated tiles are advanced to the engine <code>frame</code> (pass <a href="time-frame"><code>Time.frame</code></a>) and every tile object on the object layers is drawn too. The animation frame is a pure function of the fixed 60/s clock, so it reproduces frame-for-frame across runs and lockstep replays.

View file

@ -0,0 +1,14 @@
---
id: tiled-frame_gid
name: Tiled.frame_gid
category: tiled
kind: namespace-method
tokens: Tiled.frame_gid
sig: Tiled.frame_gid(map, gid: int, frame: int) -> int
tip: The current GID of an animated tile at a frame.
order: 18
ns: Tiled
member: frame_gid
---
Returns the GID an (animated) <code>gid</code> resolves to at engine <code>frame</code>: elapsed ms = <code>frame * 1000 / 60</code>, walked across the tileset <code>&lt;animation&gt;</code>'s frame durations to the current frame's tile — its flip flags preserved. A GID with no animation passes through unchanged.