Repository-cleanup / DX pass folding three tracker items into one coherent change, verified green end to end (`bin/x test` 49/0, `bin/x selfhost-test` 29/0, `bin/x test-tools` 29/0). #28 — curate & categorise examples/ - 42 flat entries regrouped into intent-revealing subdirs: games/, rendering/, ecs/, events/, networking/, lang/, library/ (was lib/). - chronorift dir-vs-file duplication resolved: the entry file and its import modules now live together under games/chronorift(.ludic). - Every path reference updated repo-wide (test runner, editor-tool drivers, docs/site, design docs). - New examples/README.md indexes the whole set with run commands. - Showcase examples without a self-asserting entry (hello, events, net_rt) now get a compile-only rot guard in `bin/x test`, so nothing here rots silently. #30 — text-diffable golden baseline - The 4 binary selfhost/golden/*.ppm blobs are replaced by a single selfhost/golden/renders.sha256 manifest (SHA-256 per render). Hashes are byte-identical to the old PPMs, so the baseline is unchanged — only its form. - game_case now compares framebuffer hashes; a regression shows as a changed hex line in review, not "binary files differ". - New `bin/x golden` regenerates the manifest deliberately (review with `git diff selfhost/golden/renders.sha256`). #27 — PPM & asset handling - Headless renders now write build/out.ppm, never the repo root; `x app`, `x clean`, messaging and .gitignore updated to match. Nothing is written to the working root any more. - Redundant local Kenney .zip archives removed (the art ships extracted; .gitignore already excludes *.zip). CC0 License.txt files retained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
27 lines
1.2 KiB
Text
27 lines
1.2 KiB
Text
# world_dyn.ludic — EV7 reflection: register a brand-new component at runtime
|
|
# (replaces tests/mod_c/world_dyn.c). world_register_prop declares a component the
|
|
# game never wrote; world_attach_dyn adds it to an entity; get/set/has then treat
|
|
# it exactly like a built-in, with per-entity isolation. Prints 0 1 30 100 1 30.
|
|
program WorldDyn {
|
|
property Health { hp: int = 0, max: int = 0 }
|
|
model Unit { Health }
|
|
@Public @OnSpawn(Unit) handler Init { }
|
|
|
|
entry {
|
|
let Um = world_model_id("Unit")
|
|
let e = world_spawn(Um)
|
|
let e2 = world_spawn(Um)
|
|
let Mana = world_register_prop("Mana", 2) # a component never declared in source
|
|
print(world_has(e, Mana)) # 0 — not attached yet
|
|
world_attach_dyn(e, Mana)
|
|
print(world_has(e, Mana)) # 1
|
|
world_set(e, Mana, 0, 30) # field 0 (current)
|
|
world_set(e, Mana, 1, 100) # field 1 (max)
|
|
print(world_get(e, Mana, 0)) # 30
|
|
print(world_get(e, Mana, 1)) # 100
|
|
if world_prop_id("Mana") == Mana { print(1) } else { print(0) } # 1 — name resolves
|
|
world_attach_dyn(e2, Mana)
|
|
world_set(e2, Mana, 0, 7)
|
|
print(world_get(e, Mana, 0)) # 30 — per-entity isolation
|
|
}
|
|
}
|