Tiled P3 — animated tiles (→ SpriteAnim) + tile objects #71

Closed
opened 2026-09-01 12:29:43 +02:00 by orkun · 1 comment
Owner

Follow-up P3 of the Tiled design (#66). Design record: Design: Tiled maps §3.4.

Scope — animated tiles + tile objects

  • Animated tiles: map each tileset <animation>'s <frame tileid= duration=> list onto the existing SpriteAnim engine-owned system (the compiler already auto-ticks SpriteAnim each frame). An animated GID resolves to a SpriteAnim cursor; frame = f(elapsed), deterministic, ticks for free.
  • Tile objects: object-layer entries with a gid render the tile image (with their own flip flags) as a placeable/rotatable sprite.

Golden fixtures

rpg/island.tmx + beach_tileset.tsx (33 <animation> blocks / 131 <frame>s); sticker-knight/ (tile objects with flip flags).

Acceptance

  • Animated tiles advance frames at the authored durations and are frame-identical across runs.
  • Tile objects draw at their position with correct GID flips.

Depends on #69. Priority medium.

Follow-up P3 of the Tiled design (#66). Design record: [Design: Tiled maps](https://git.workshopsoft.io/workshopsoft/ludic/wiki/Design%2FTiled) §3.4. ## Scope — animated tiles + tile objects - **Animated tiles**: map each tileset `<animation>`'s `<frame tileid= duration=>` list onto the existing **SpriteAnim engine-owned system** (the compiler already auto-ticks SpriteAnim each frame). An animated GID resolves to a SpriteAnim cursor; frame = f(elapsed), deterministic, ticks for free. - **Tile objects**: object-layer entries with a `gid` render the tile image (with their own flip flags) as a placeable/rotatable sprite. ## Golden fixtures `rpg/island.tmx` + `beach_tileset.tsx` (33 `<animation>` blocks / 131 `<frame>`s); `sticker-knight/` (tile objects with flip flags). ## Acceptance - [ ] Animated tiles advance frames at the authored durations and are frame-identical across runs. - [ ] Tile objects draw at their position with correct GID flips. Depends on #69. Priority medium.
orkun added the
priority:medium
area:stdlib
area:rendering
labels 2026-09-01 12:29:43 +02:00
Author
Owner

P3 landed in main (58e1105).

  • 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): elapsed ms = frame * 1000 / 60, walked across the frame durations to the current one. 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 (pass Time.frame).
  • 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 renders object layers alongside tile layers.

Acceptance

  • Animated tiles advance frames at the authored durations and are frame-identical across runs — frame_gid at 0/100/200/300 ms hits local 0/40/80/0 (wrap), and the flip flags ride an animation swap.
  • Tile objects draw at their position with correct GID flips — an object-layer tile object parses (gid/x/y) and draws; an H-flipped tile object mirrors pixel-for-pixel.

Also validated against the design's named fixture rpg/beach_tileset.tsx (33 <animation> blocks / 131 <frame>s). Proven by examples/library/tiled_p3.ludic (14 assertions) in x test (94 passed).

**P3 landed** in `main` (58e1105). - **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): `elapsed ms = frame * 1000 / 60`, walked across the frame durations to the current one. 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 (pass `Time.frame`). - **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` renders object layers alongside tile layers. ### Acceptance - [x] Animated tiles advance frames at the authored durations and are frame-identical across runs — `frame_gid` at 0/100/200/300 ms hits local 0/40/80/0 (wrap), and the flip flags ride an animation swap. - [x] Tile objects draw at their position with correct GID flips — an object-layer tile object parses (gid/x/y) and draws; an H-flipped tile object mirrors pixel-for-pixel. Also validated against the design's named fixture `rpg/beach_tileset.tsx` (**33 `<animation>` blocks / 131 `<frame>`s**). Proven by `examples/library/tiled_p3.ludic` (14 assertions) in `x test` (94 passed).
orkun closed this issue 2026-09-01 13:58:35 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: workshopsoft/ludic#71
No description provided.