Engine sprite-render system: auto-draw Sprite/SpriteAnim components; namespace draw_sprite #85

Closed
opened 2026-09-02 04:52:43 +02:00 by orkun · 1 comment
Owner

There is no engine system that draws entities' sprites. Games write a manual Render handler that queries positions and calls draw_sprite per entity, and hand-animate. The engine already auto-ticks SpriteAnim/Motion; it should also auto-DRAW a Sprite/SpriteAnim component (layer/offset/flip/tint, camera, z-order) so the common case is declarative: attach a Sprite, the engine renders it. Games opt out for custom draw.

Also: draw_sprite/draw_sprite_scaled are bare unnamespaced globals; Screen.sprite already exists — the bare aliases should be deprecated/removed so the API is consistently namespaced.

There is no engine system that draws entities' sprites. Games write a manual Render handler that queries positions and calls `draw_sprite` per entity, and hand-animate. The engine already auto-ticks SpriteAnim/Motion; it should also auto-DRAW a Sprite/SpriteAnim component (layer/offset/flip/tint, camera, z-order) so the common case is declarative: attach a Sprite, the engine renders it. Games opt out for custom draw. Also: `draw_sprite`/`draw_sprite_scaled` are bare unnamespaced globals; `Screen.sprite` already exists — the bare aliases should be deprecated/removed so the API is consistently namespaced.
Author
Owner

Shipped in 57b8747 (real implementation, tested — full suite 109/0, golden renders byte-identical, C-free bootstrap fixpoint intact).

Engine sprite-render system. The engine already auto-ticks SpriteAnim/Motion; it now auto-draws too. Declare a Sprite component (id + optional offx/offy/scale/flip/tint/hidden, shipped from ludic.core) on an entity with a Position and esys_sprite draws it each Render frame — no hand-written Render handler querying positions and calling draw_sprite per entity, and no hand animation: when the entity also carries SpriteAnim, the current frame is added to the base id automatically. It is registered on the compile-time engine-system registry for the Render phase and spliced only when a game declares Sprite, so a game that never declares it compiles byte-identically; a game wanting a custom draw omits Sprite or disable system esys_sprite.

Namespaced draw_sprite. The bare draw_sprite / draw_sprite_scaled globals are deprecated in favour of Screen.sprite / Screen.sprite_scaled: a direct bare call now emits a one-time compile-time deprecation note (the bare form still lowers, since Screen.sprite uses it internally), and the in-repo chronorift demo is migrated to the namespaced calls (its golden render is byte-identical).

Verified by examples/library/sprite_render.ludic: declares Sprite from ludic.core on two entities, empty Render handler, and pixel-readback confirms the engine drew the shown sprite and skipped the hidden one. Wired as a controller_case; docs updated.

Shipped in 57b8747 (real implementation, tested — full suite 109/0, golden renders byte-identical, C-free bootstrap fixpoint intact). **Engine sprite-render system.** The engine already auto-*ticks* SpriteAnim/Motion; it now auto-*draws* too. Declare a `Sprite` component (id + optional offx/offy/scale/flip/tint/hidden, shipped from **ludic.core**) on an entity with a `Position` and `esys_sprite` draws it each Render frame — no hand-written Render handler querying positions and calling draw_sprite per entity, and no hand animation: when the entity also carries `SpriteAnim`, the current frame is added to the base id automatically. It is registered on the compile-time engine-system registry for the Render phase and spliced only when a game declares `Sprite`, so a game that never declares it compiles **byte-identically**; a game wanting a custom draw omits `Sprite` or `disable system esys_sprite`. **Namespaced draw_sprite.** The bare `draw_sprite` / `draw_sprite_scaled` globals are deprecated in favour of `Screen.sprite` / `Screen.sprite_scaled`: a direct bare call now emits a one-time compile-time deprecation note (the bare form still lowers, since `Screen.sprite` uses it internally), and the in-repo `chronorift` demo is migrated to the namespaced calls (its golden render is byte-identical). Verified by `examples/library/sprite_render.ludic`: declares Sprite from ludic.core on two entities, empty Render handler, and pixel-readback confirms the engine drew the shown sprite and skipped the `hidden` one. Wired as a controller_case; docs updated.
orkun closed this issue 2026-09-02 06:20:29 +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#85
No description provided.