ludic/examples/scenes.ludic
Orkuncakilkaya cc701013f5 Phase 6e: unify builtin naming (loaders domain-first, set_reg)
Fixed the naming inconsistencies the cohesion audit flagged, converging on the
domain-first style the bulk of the surface already uses (ui_*, text_*, rng_*,
font_load, image_load):

  - load_png    -> png_load       (asset loaders were split: font_load/image_load
  - load_sprites -> sprites_load   were domain-first, load_* were verb-first)
  - setreg      -> set_reg        (missing underscore vs ui_set_int/ui_set_text)

Game builtins resolve to their `rt_` runtime function, so the renames are in
runtime/native (rt_png_load, rt_sprites_load, rt_set_reg) plus the ~100 example
call sites; `become` lowering in emit_machine now emits @fn_rt_set_reg. Purely a
surface rename — every renamed call maps to the same runtime symbol, so behavior
and golden renders are byte-identical.

Vocabulary + docs updated (ludic_syntax.h, grammar, LudicTokens.kt, LANGUAGE.md,
README, SYNTAX-REDESIGN). Reseeded; C-free fixpoint holds; goldens identical;
17/17; vocab clean.

Left as-is: os_argc/os_arg (compiler-internal intrinsics, already namespaced and
consistent with each other; renaming would need a bootstrap dance for little
gain). reg/set_reg keep the getter-bare/setter-set_ shape ui_focused/ui_set_int
already use.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-27 23:38:10 +03:00

38 lines
1.1 KiB
Text

# ⚠️ NOT YET IMPLEMENTED by the self-hosted compiler. `scene` / `layer` /
# `on enter` / `on exit` have no parser support today, so this file does NOT
# compile with build/ludicc — it is a design sketch of the intended syntax (see
# LANGUAGE.md §"Scenes & layers"). It is deliberately excluded from test.sh.
# Games that need scene-like states use a mode register + `machine` today, as
# examples/chronorift does.
program SceneDemo {
const R_N: int = 0
handler Boot phase Start { set_reg(R_N, 0); print_int(1000) }
scene Title start {
on enter { print_int(1) }
on exit { print_int(2) }
layer Main {
handler Tick phase Update {
set_reg(R_N, reg(R_N) + 1)
print_int(100 + reg(R_N))
if reg(R_N) >= 2 { become Play }
}
}
}
scene Play {
on enter { print_int(3); set_reg(R_N, 0) }
on exit { print_int(4) }
layer World {
handler Step phase Update {
set_reg(R_N, reg(R_N) + 1)
print_int(200 + reg(R_N))
if reg(R_N) >= 2 { quit() }
}
}
layer Hud {
handler Draw phase Render { print_int(900) }
}
}
}