feat(assets): #81 namespaced spritesheet/atlas API (Sprite.* / Assets.*)
Sprite loading was a bare png_load — one file per 16x16 sprite, no way to load one sheet and address a cell by grid coords or name. Adds a Sprite.*/Assets.* runtime (atlas.ludic) over the variable-size image loader, so a cell is a sub-rect of the kept image and is NOT restricted to the 16x16 sprite table: Sprite.sheet(path,cw,ch), Sprite.cell(sheet,col,row), Sprite.cell_span(sheet,col,row,cols,rows) (a sprite may span >1 cell), Sprite.define/named (name + lookup), Sprite.draw/draw_scaled (through camera/zoom/clip like Screen.sprite), Sprite.width/height, and Assets.image/load/get. Spliced on demand (Sprite.sheet/… or Assets.*), so a program using neither is byte-identical. Example examples/library/atlas.ludic (verified against a real 12x11 Kenney sheet, incl. a 2x3 multi-cell span and named lookup). 14 docs pages. Full suite 114/0, goldens byte-identical, fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ab4546e365
commit
f3f1336882
21 changed files with 34542 additions and 32915 deletions
|
|
@ -176,6 +176,27 @@ function emit_ns_call(ns: pointer, meth: pointer, e: Node) -> Val {
|
|||
if (meth == "measure_text") { bare = "measure_text"; push(labels, "text") }
|
||||
if (meth == "pixel") { bare = "get_px"; push(labels, "x"); push(labels, "y") }
|
||||
}
|
||||
# Sprite.* / Assets.* — the namespaced spritesheet / atlas API (#81), a runtime
|
||||
# in atlas.ludic over the variable-size image loader. A cell (or multi-cell span)
|
||||
# is a sub-rect of a loaded sheet; draws go through rt_put_px so camera/zoom/clip
|
||||
# apply. Distinct from the `Sprite` engine component (#85) — same name, different
|
||||
# namespace (a namespaced builtin, never an entity).
|
||||
if (ns == "Sprite") {
|
||||
if (meth == "sheet") { bare = "atlas_sheet"; push(labels, "path"); push(labels, "cellw"); push(labels, "cellh") }
|
||||
if (meth == "cell") { bare = "atlas_cell"; push(labels, "sheet"); push(labels, "col"); push(labels, "row") }
|
||||
if (meth == "cell_span") { bare = "atlas_cell_span"; push(labels, "sheet"); push(labels, "col"); push(labels, "row"); push(labels, "cols"); push(labels, "rows") }
|
||||
if (meth == "define") { bare = "atlas_define"; push(labels, "name"); push(labels, "sheet"); push(labels, "col"); push(labels, "row") }
|
||||
if (meth == "named") { bare = "atlas_named"; push(labels, "name") }
|
||||
if (meth == "draw") { bare = "atlas_draw"; push(labels, "id"); push(labels, "x"); push(labels, "y") }
|
||||
if (meth == "draw_scaled") { bare = "atlas_draw_scaled"; push(labels, "id"); push(labels, "x"); push(labels, "y"); push(labels, "scale") }
|
||||
if (meth == "width") { bare = "atlas_width"; push(labels, "id") }
|
||||
if (meth == "height") { bare = "atlas_height"; push(labels, "id") }
|
||||
}
|
||||
if (ns == "Assets") {
|
||||
if (meth == "image") { bare = "atlas_image"; push(labels, "path") }
|
||||
if (meth == "load") { bare = "atlas_image"; push(labels, "path") } # alias
|
||||
if (meth == "get") { bare = "atlas_named"; push(labels, "name") } # alias of Sprite.named
|
||||
}
|
||||
# Camera.* — the world-space camera: a draw offset threaded through the render
|
||||
# path (runtime/native/core.ludic). set/follow move it; shake jitters it from
|
||||
# the seeded RNG, so a replay shakes identically.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue