ludic/examples/ecs/hello.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

33 lines
746 B
Text

# hello.ludic — smallest program that exercises the ECS pipeline
program Hello {
property Pos { x: int = 0, y: int = 0 }
property Vel { dx: int = 0, dy: int = 0 }
handler Boot phase Start {
spawn Mob {
Pos { x: 3, y: 4 }
Vel { dx: 1, dy: 0 }
}
spawn Mob {
Pos { x: 10, y: 2 }
Vel { dx: 0, dy: 1 }
}
}
# a handler declares the entities it operates on with @Queries: the body then
# runs once per match, each property bound by name and self() giving that entity.
@Queries(these: [Pos, Vel])
handler Move phase FixedUpdate {
Pos.x += Vel.dx
Pos.y += Vel.dy
}
handler Report phase Update {
for (p) in query [Pos] {
print(p.x)
print(p.y)
}
quit()
}
}