- 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>
140 lines
4.2 KiB
Text
140 lines
4.2 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 -= 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 -= 10
|
|
potions += 1
|
|
}
|
|
}
|
|
if menu_cursor == 1 { game_mode = 0 }
|
|
}
|
|
}
|
|
}
|