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
29
examples/lang/offline_rewards.ludic
Normal file
29
examples/lang/offline_rewards.ludic
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# offline_rewards.ludic — issue #9's worked example: an idle/farming game grants
|
||||
# "you were away for N hours" rewards on load, using the Time/Date/Duration and
|
||||
# the deterministic Clock. Everything is integer seconds, so the result replays
|
||||
# identically — no wall clock, no floating point.
|
||||
#
|
||||
# bin/ludic examples/lang/offline_rewards.ludic # prints 13 / 650 / 2026-08-30 / 0
|
||||
program OfflineRewards {
|
||||
entry {
|
||||
# A save records when the player last quit. It is hardcoded here so the demo
|
||||
# is deterministic; a real game writes Time.now() (or Clock.now()) at save.
|
||||
let last_seen = DateTime.from(2026, 8, 29, 18, 30, 0)
|
||||
|
||||
# On load, set the game clock to "now". We drive it explicitly (rather than
|
||||
# Time.now) so gameplay stays replay-safe and this sample is reproducible.
|
||||
Clock.set(DateTime.from(2026, 8, 30, 7, 45, 0))
|
||||
|
||||
let away = Clock.now() - last_seen # a Duration in seconds (47700)
|
||||
let hours = Duration.as_hours(away) # whole hours away
|
||||
|
||||
# Reward: 50 coins per full hour, capped at a day's worth.
|
||||
let capped = Math.min(hours, 24)
|
||||
let coins = capped * 50
|
||||
|
||||
print(hours) # 13
|
||||
print(coins) # 650
|
||||
print(DateTime.format(Clock.now(), "YYYY-MM-DD")) # 2026-08-30 (the day they returned)
|
||||
print(DateTime.weekday(Clock.now())) # 0 = Sunday
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue