ludic/examples/library/input_auto.ludic
Orkuncakilkaya bf36bc8a8f 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>
2026-09-05 01:12:26 +03:00

20 lines
888 B
Text

# input_auto.ludic — proves the frame loop commits the device layer automatically
# (#83): a real handler game reads Input.active in its Update phase and NEVER calls
# Input.poll by hand, yet the action fires from the live key. Before this fix the
# loop only fed Input.key(), so Input.active read empty unless the game polled.
#
# Driven headless by the keys on stdin — one char per frame. With "llq": frame 1
# and 2 read 'l' (the action key), frame 3 reads 'q' (which quits). So the action
# is active on exactly two frames.
#
# Run: printf 'llq' | bin/ludic examples/library/input_auto.ludic -> 2
program InputAuto {
property Tag { n: int = 0 }
model Player { Tag }
var hits: int = 0
@OnStart handler Boot { Input.action("go", 'l') } # 'l' == 108
handler Sense phase Update { if Input.active("go") { hits += 1 } }
@OnQuit handler Report { print(hits) }
}