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>
This commit is contained in:
parent
0bc5d76952
commit
fb728bbefe
73 changed files with 364 additions and 194 deletions
32
examples/events/promote.ludic
Normal file
32
examples/events/promote.ludic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# promote.ludic — EV1: `@Public` promotes a lifecycle hook to a public event.
|
||||
#
|
||||
# Marking a lifecycle hook `@Public` makes its fire site ALSO emit an event named
|
||||
# for the moment — `model_<M>_spawn`, `model_<M>_despawn` — carrying the entity
|
||||
# (and, for despawn, the EndReason). Anything can then subscribe: a native
|
||||
# listener with `@On(model_Enemy_spawn)`, or a foreign mod binding
|
||||
# `ludic_on_model_Enemy_spawn` over the C ABI. The game's own lifecycle becomes
|
||||
# the modding surface, with no hand-written `emit` in the hook body.
|
||||
#
|
||||
# Running it prints: 100 101 200 201
|
||||
program Promote {
|
||||
property Health { hp: int = 0, max: int = 100 }
|
||||
model Enemy { Health }
|
||||
|
||||
@Public @OnSpawn(Enemy) handler Init { Health.hp = Health.max } # -> model_Enemy_spawn
|
||||
@Public @OnDespawn(Enemy) handler Clean { } # -> model_Enemy_despawn
|
||||
|
||||
# Listeners on the promoted events. These read the generated payload (entity,
|
||||
# and reason for despawn) by name — exactly what a foreign mod receives.
|
||||
@On(model_Enemy_spawn) handler Spawned { print(entity + 100) }
|
||||
@On(model_Enemy_despawn) handler Died { print(entity + reason + 200) }
|
||||
|
||||
handler Seed phase Start {
|
||||
spawn Enemy { Health { max: 50 } } # entity 0 -> Spawned 100
|
||||
spawn Enemy { Health { max: 60 } } # entity 1 -> Spawned 101
|
||||
}
|
||||
|
||||
handler Run phase Update {
|
||||
for (h) in query [Health] { despawn self() } # despawn 0 -> Died 200, despawn 1 -> Died 201
|
||||
quit()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue