refactor(runtime,packages,examples): named constants, package enums, idiom sweep

- runtime: HEADLESS_FRAME_PATH, STICK_DEADZONE / STICK_LEFT_X/Y, key and
  byte codes as char literals throughout (`k == 'w'`, `fill(rt_map, ' ', …)`)
- ludic.gameplay/stats: drop the duplicate `stat_field` (it answered "atk"
  for every build stat); Stats.base uses stats_field_name
- ludic.shooter: compare aim modes and fire patterns with AimMode.* and
  WeaponPattern.* instead of raw ints; STICK_RIGHT_X/Y
- ludic.npcai: DecisionMade / brain_set_state use AiState.*
- examples/games/menu.ludic uses Font.load / Ui.* with FONT_PATH and
  BACKDROP named; strings.ludic header says what it prints
- whole tree: `x = x + 1` → `x += 1` (single-term right-hand sides only),
  `0 - x` → `-x`, ASCII codes → char literals; every .ludic and every
  ```ludic fence reformatted with the fixed formatter (whitespace only)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-05 01:12:26 +03:00
parent e3e1bc7784
commit bf36bc8a8f
103 changed files with 1256 additions and 1252 deletions

View file

@ -20,8 +20,8 @@ program Cancel {
# the realistic shape: only apply the effect when the decision isn't vetoed
var hp = 100
if emit BeforeHurt(amount: 8) == 0 { hp = hp - 8 } # allowed -> 92
if emit BeforeHurt(amount: 50) == 0 { hp = hp - 50 } # vetoed -> unchanged
if emit BeforeHurt(amount: 8) == 0 { hp -= 8 } # allowed -> 92
if emit BeforeHurt(amount: 50) == 0 { hp -= 50 } # vetoed -> unchanged
print(hp) # 92
}
}

View file

@ -17,7 +17,7 @@ program LayerEvents {
}
layer Ctrl {
handler Drive phase LateUpdate {
step = step + 1
step += 1
if step == 1 { disable layer Hud } # frame 1: hide -> Hidden 2, Draw stops
if step == 2 { enable layer Hud } # frame 2: show -> Shown 1, Draw resumes
if step == 3 { quit() } # frame 3: after Draw ran again

View file

@ -6,7 +6,7 @@ program ModEvents {
var total: int = 0
event Damage { amount: int = 0 }
@On(Damage) handler Native { print(amount) } # prints each hit
@On(Damage) handler Accum { total = total + amount } # sums them
@On(Damage) handler Accum { total += amount } # sums them
entry {
emit Damage(amount: 10) # Native prints 10

View file

@ -11,8 +11,8 @@ program ProgramEvents {
@Public @OnStart handler Boot { print(1) } # -> program_start
@Public @OnQuit handler Bye { print(2) } # -> program_quit
@On(program_start) handler ModInit { print(100) } # mod boots after the game
@On(program_quit) handler ModDone { print(200) } # mod tears down as the game exits
@On(program_start) handler ModInit { print(100) } # mod boots after the game
@On(program_quit) handler ModDone { print(200) } # mod tears down as the game exits
handler Run phase Update { quit() }
}

View file

@ -11,7 +11,7 @@ program Recurse {
event Ping { }
event Pong { }
@On(Ping) handler A { n = n + 1; emit Pong() } # each Ping deepens by one Pong
@On(Ping) handler A { n += 1; emit Pong() } # each Ping deepens by one Pong
@On(Pong) handler B { emit Ping() } # ...and each Pong by one Ping
entry {

View file

@ -8,7 +8,7 @@ program Scoped {
model Unit { Health }
var fires: int = 0
event Tick { }
@On(Tick) handler OnTick { for (Health) in query [Health, {Unit}] { fires = fires + 1 } }
@On(Tick) handler OnTick { for (Health) in query [Health, {Unit}] { fires += 1 } }
entry {
spawn Unit { Health { hp: 1 } }