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>
140 lines
4.1 KiB
Text
140 lines
4.1 KiB
Text
# overworld.ludic — boot, movement/encounter input, and the shop system.
|
|
|
|
handler Boot phase Start {
|
|
png_load("assets/kenney/tiny-town/Tiles/tile_0000.png") # 0 grass
|
|
png_load("assets/kenney/tiny-town/Tiles/tile_0004.png") # 1 tree
|
|
png_load("assets/kenney/tiny-town/Tiles/tile_0025.png") # 2 path
|
|
png_load("assets/kenney/tiny-town/Tiles/tile_0073.png") # 3 house
|
|
png_load("assets/kenney/tiny-town/Tiles/tile_0112.png") # 4 arch
|
|
png_load("assets/kenney/tiny-dungeon/Tiles/tile_0096.png") # 5 hero
|
|
png_load("assets/kenney/tiny-dungeon/Tiles/tile_0108.png") # 6 slime
|
|
png_load("assets/kenney/tiny-dungeon/Tiles/tile_0120.png") # 7 skeleton
|
|
png_load("assets/kenney/tiny-dungeon/Tiles/tile_0110.png") # 8 boss
|
|
png_load("assets/kenney/tiny-dungeon/Tiles/tile_0084.png") # 9 mage
|
|
png_load("assets/kenney/tiny-dungeon/Tiles/tile_0048.png") # 10 floor
|
|
png_load("assets/kenney/tiny-dungeon/Tiles/tile_0026.png") # 11 wall
|
|
|
|
build_field(0)
|
|
spawn Player {
|
|
Pos { x: 11, y: 15 }
|
|
Actor { kind: 5 }
|
|
Party { slot: 0 }
|
|
Stats { hp: 40, maxhp: 40, mp: 8, maxmp: 8, atk: 12, def: 6, lvl: 1, xp: 0, guard: 0 }
|
|
}
|
|
spawn Ally {
|
|
Party { slot: 1 }
|
|
Stats { hp: 26, maxhp: 26, mp: 16, maxmp: 16, atk: 8, def: 4, lvl: 1, xp: 0, guard: 0 }
|
|
}
|
|
game_mode = 0
|
|
encounter = 4
|
|
world_map = 0
|
|
boss_down = 0
|
|
gold = 20
|
|
potions = 2
|
|
}
|
|
|
|
handler Control phase Input {
|
|
if game_mode == 0 {
|
|
for (p) in query [Pos, {Player}] {
|
|
let k = Input.key()
|
|
var nx = p.x
|
|
var ny = p.y
|
|
if k == 'w' { ny = p.y - 1 }
|
|
if k == 's' { ny = p.y + 1 }
|
|
if k == 'a' { nx = p.x - 1 }
|
|
if k == 'd' { nx = p.x + 1 }
|
|
var moved = 0
|
|
if walkable(nx, ny) {
|
|
if nx != p.x or ny != p.y {
|
|
p.x = nx
|
|
p.y = ny
|
|
moved = 1
|
|
}
|
|
}
|
|
if moved == 1 {
|
|
let tc = Map.tile(p.x, p.y)
|
|
if tc == 'D' {
|
|
build_dungeon(0)
|
|
p.x = 3
|
|
p.y = 2
|
|
world_map = 1
|
|
}
|
|
if tc == 'S' {
|
|
build_field(0)
|
|
p.x = 36
|
|
p.y = 3
|
|
world_map = 0
|
|
}
|
|
if tc == 'B' {
|
|
if boss_down == 0 {
|
|
enemy_type = 2
|
|
spawn Enemy {
|
|
Actor { kind: 8 }
|
|
Stats { hp: 120, maxhp: 120, mp: 0, maxmp: 0, atk: 18, def: 10, lvl: 5, xp: 300, guard: 0 }
|
|
}
|
|
game_mode = 1
|
|
turn_phase = 0
|
|
menu_cursor = 0
|
|
}
|
|
}
|
|
if tc == 'h' {
|
|
game_mode = 4
|
|
menu_cursor = 0
|
|
}
|
|
if tc != 'D' {
|
|
if tc != 'S' {
|
|
if tc != 'B' {
|
|
if tc != 'h' {
|
|
encounter = encounter - 1
|
|
if encounter <= 0 {
|
|
encounter = Random.range(4, 9)
|
|
var et = 0
|
|
if world_map == 1 { et = 1 }
|
|
if world_map == 0 {
|
|
if Random.chance(40) { et = 1 }
|
|
}
|
|
enemy_type = et
|
|
if et == 0 {
|
|
spawn Enemy {
|
|
Actor { kind: 6 }
|
|
Stats { hp: 18, maxhp: 18, mp: 0, maxmp: 0, atk: 8, def: 2, lvl: 1, xp: 7, guard: 0 }
|
|
}
|
|
}
|
|
if et == 1 {
|
|
spawn Enemy {
|
|
Actor { kind: 7 }
|
|
Stats { hp: 30, maxhp: 30, mp: 0, maxmp: 0, atk: 11, def: 5, lvl: 1, xp: 15, guard: 0 }
|
|
}
|
|
}
|
|
game_mode = 1
|
|
turn_phase = 0
|
|
menu_cursor = 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if k == 'k' { save() }
|
|
if k == 'l' { if load() { } }
|
|
}
|
|
}
|
|
}
|
|
|
|
# shop (at the house 'h' tile): buy potions with gold
|
|
handler Shop phase Update {
|
|
if game_mode == 4 {
|
|
let k = Input.key()
|
|
if k == 'w' { menu_cursor = max(0, menu_cursor - 1) }
|
|
if k == 's' { menu_cursor = min(1, menu_cursor + 1) }
|
|
if is_confirm(k) {
|
|
if menu_cursor == 0 {
|
|
if gold >= 10 {
|
|
gold = gold - 10
|
|
potions = potions + 1
|
|
}
|
|
}
|
|
if menu_cursor == 1 { game_mode = 0 }
|
|
}
|
|
}
|
|
}
|