Language: named colors, namespaced Screen/Input/Random/Map API, named args

An opinionated, game-facing surface for the language:
- Color.<Name>: 221 named colors resolved to 0xRRGGBB at compile time
  (selfhost/emit_color.ludic).
- Namespaced builtins Screen.* / Input.key / Random.* / Map.*, so calls read as
  subject.action; present() -> Screen.show(), clear -> Screen.clear,
  fill_rect -> Screen.fill_rectangle, etc.
- Named arguments, e.g. Screen.fill_rectangle(x:, y:, width:, height:, color:),
  reordered to the callee's parameters at emit time.
- machine/become can run over a named program-scope var, not just a register.
- Migrate examples off numeric registers to named vars; snake/menu/chronorift
  render byte-identical to the goldens and the bootstrap fixpoint is preserved.
- Regenerate the checked-in seed (selfhost/ludicc.seed.ll).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-08-29 16:05:55 +03:00
parent 9e4837428c
commit a3a1e4d160
14 changed files with 11784 additions and 7493 deletions

View file

@ -1,50 +1,50 @@
# combat.ludic — the co-op turn-based battle state machine.
# The battle is a state machine over R_PHASE. `machine` dispatches on the
# register and `become` transitions to a named state — no more `if ph == N`
# ladders. Knight turn (0,1), Mage turn (2,3), Enemy turn (4).
# The battle is a state machine over the `turn_phase` variable. `machine`
# dispatches on its value and `become` transitions to a named state — no more
# `if ph == N` ladders. Knight turn (0,1), Mage turn (2,3), Enemy turn (4).
# Menu selections, named instead of matched on bare integers (R_CUR holds one).
# Menu selections, named instead of matched on bare integers (menu_cursor holds one).
enum KnightAct { Attack, Guard, Item, Flee }
enum MageAct { Attack, Heal, Guard }
handler Battle phase Update {
if reg(R_MODE) == 1 {
let k = key()
if game_mode == 1 {
let k = Input.key()
for (e) in query [Stats, {Enemy}] {
machine R_PHASE {
machine turn_phase {
state KnightMenu {
for (st, pt) in query [Stats, Party] {
if pt.slot == 0 {
if st.hp <= 0 {
become MageMenu
set_reg(R_CUR, 0)
menu_cursor = 0
} else {
if k == 'w' { set_reg(R_CUR, max(0, reg(R_CUR) - 1)) }
if k == 's' { set_reg(R_CUR, min(3, reg(R_CUR) + 1)) }
if k == 'w' { menu_cursor = max(0, menu_cursor - 1) }
if k == 's' { menu_cursor = min(3, menu_cursor + 1) }
if is_confirm(k) {
match reg(R_CUR) {
match menu_cursor {
KnightAct.Attack => {
let d = max(1, st.atk - e.def + rng_range(0, 4))
let d = max(1, st.atk - e.def + Random.range(0, 4))
e.hp = e.hp - d
set_reg(R_PDMG, d)
player_hit = d
}
KnightAct.Guard => { st.guard = 1; set_reg(R_PDMG, 0) }
KnightAct.Guard => { st.guard = 1; player_hit = 0 }
KnightAct.Item => {
if reg(R_POTION) > 0 {
set_reg(R_POTION, reg(R_POTION) - 1)
if potions > 0 {
potions = potions - 1
st.hp = min(st.maxhp, st.hp + 24)
set_reg(R_PDMG, 24)
} else { set_reg(R_PDMG, 0) }
player_hit = 24
} else { player_hit = 0 }
}
KnightAct.Flee => {
if rng_chance(50) { e.hp = 0; set_reg(R_MODE, 0) }
else { set_reg(R_PDMG, 0) }
if Random.chance(50) { e.hp = 0; game_mode = 0 }
else { player_hit = 0 }
}
}
become KnightResolve
set_reg(R_CUR, 0)
menu_cursor = 0
}
}
}
@ -55,13 +55,13 @@ handler Battle phase Update {
if k != 0 {
if e.hp <= 0 {
grant_xp(e.xp)
set_reg(R_GOLD, reg(R_GOLD) + e.xp)
if reg(R_ETYPE) == 2 { set_reg(R_BOSS, 1); set_reg(R_MODE, 3); set_reg(R_ACK, 0) }
else { set_reg(R_MODE, 0) }
gold = gold + e.xp
if enemy_type == 2 { boss_down = 1; game_mode = 3; ack = 0 }
else { game_mode = 0 }
become KnightMenu
} else {
become MageMenu
set_reg(R_CUR, 0)
menu_cursor = 0
}
}
}
@ -72,14 +72,14 @@ handler Battle phase Update {
if st.hp <= 0 {
become EnemyTurn
} else {
if k == 'i' { set_reg(R_CUR, max(0, reg(R_CUR) - 1)) }
if k == 'k' { set_reg(R_CUR, min(2, reg(R_CUR) + 1)) }
if k == 'i' { menu_cursor = max(0, menu_cursor - 1) }
if k == 'k' { menu_cursor = min(2, menu_cursor + 1) }
if k == 'j' {
match reg(R_CUR) {
match menu_cursor {
MageAct.Attack => {
let d = max(1, st.atk + 5 - e.def + rng_range(0, 5))
let d = max(1, st.atk + 5 - e.def + Random.range(0, 5))
e.hp = e.hp - d
set_reg(R_PDMG, d)
player_hit = d
}
MageAct.Heal => {
if st.mp >= 4 {
@ -87,13 +87,13 @@ handler Battle phase Update {
for (t2, p2) in query [Stats, Party] {
if p2.slot == 0 { t2.hp = min(t2.maxhp, t2.hp + 16) }
}
set_reg(R_PDMG, 16)
} else { set_reg(R_PDMG, 0) }
player_hit = 16
} else { player_hit = 0 }
}
MageAct.Guard => { st.guard = 1; set_reg(R_PDMG, 0) }
MageAct.Guard => { st.guard = 1; player_hit = 0 }
}
become MageResolve
set_reg(R_CUR, 0)
menu_cursor = 0
}
}
}
@ -104,9 +104,9 @@ handler Battle phase Update {
if k != 0 {
if e.hp <= 0 {
grant_xp(e.xp)
set_reg(R_GOLD, reg(R_GOLD) + e.xp)
if reg(R_ETYPE) == 2 { set_reg(R_BOSS, 1); set_reg(R_MODE, 3); set_reg(R_ACK, 0) }
else { set_reg(R_MODE, 0) }
gold = gold + e.xp
if enemy_type == 2 { boss_down = 1; game_mode = 3; ack = 0 }
else { game_mode = 0 }
become KnightMenu
} else {
become EnemyTurn
@ -120,10 +120,10 @@ handler Battle phase Update {
for (t3) in query [Stats, {Party}] {
if done == 0 {
if t3.hp > 0 {
var ed = max(1, e.atk - t3.def + rng_range(0, 4))
var ed = max(1, e.atk - t3.def + Random.range(0, 4))
if t3.guard == 1 { ed = ed / 2; t3.guard = 0 }
t3.hp = t3.hp - ed
set_reg(R_EDMG, ed)
enemy_hit = ed
done = 1
}
}
@ -132,10 +132,10 @@ handler Battle phase Update {
for (t4) in query [Stats, {Party}] {
if t4.hp > 0 { alive = alive + 1 }
}
if alive == 0 { set_reg(R_MODE, 2); set_reg(R_ACK, 0) }
if alive == 0 { game_mode = 2; ack = 0 }
else {
become KnightMenu
set_reg(R_CUR, 0)
menu_cursor = 0
}
}
}
@ -145,7 +145,7 @@ handler Battle phase Update {
}
handler CleanBattle phase LateUpdate {
if reg(R_MODE) != 1 {
if game_mode != 1 {
for (e) in query [Stats, {Enemy}] {
despawn self()
}
@ -153,20 +153,20 @@ handler CleanBattle phase LateUpdate {
}
handler Meta phase Update {
let k = key()
if reg(R_MODE) == 2 {
if k == 0 { set_reg(R_ACK, 1) }
let k = Input.key()
if game_mode == 2 {
if k == 0 { ack = 1 }
if k != 0 {
if reg(R_ACK) == 1 {
if ack == 1 {
for (h) in query [Stats, {Party}] { h.hp = h.maxhp }
set_reg(R_MODE, 0)
game_mode = 0
}
}
}
if reg(R_MODE) == 3 {
if k == 0 { set_reg(R_ACK, 1) }
if game_mode == 3 {
if k == 0 { ack = 1 }
if k != 0 {
if reg(R_ACK) == 1 { set_reg(R_MODE, 0) }
if ack == 1 { game_mode = 0 }
}
}
}

View file

@ -1,8 +1,8 @@
# draw.ludic — the Render system (overworld, battle, and overlay screens).
handler Draw phase Render {
let m = reg(R_MODE)
clear(0x101018)
let m = game_mode
Screen.clear(0x101018)
if m == 0 {
var cx = 0
@ -15,7 +15,7 @@ handler Draw phase Render {
let ty0 = cy / 16
for ty in ty0 .. ty0 + 16 {
for tx in tx0 .. tx0 + 21 {
let c = tile(tx, ty)
let c = Map.tile(tx, ty)
let sx = tx * 16 - cx
let sy = ty * 16 - cy
var base = SPR_GRASS
@ -31,7 +31,7 @@ handler Draw phase Render {
if c == 'D' { draw_sprite(SPR_DOOR, sx, sy) }
if c == 'S' { draw_sprite(SPR_DOOR, sx, sy) }
if c == 'B' {
if reg(R_BOSS) == 0 { draw_sprite(SPR_BOSS, sx, sy) }
if boss_down == 0 { draw_sprite(SPR_BOSS, sx, sy) }
}
}
}
@ -40,99 +40,99 @@ handler Draw phase Render {
}
for (h, pp) in query [Stats, Party] {
if pp.slot == 0 {
fill_rect(4, 4, 96, 38, 0x0c0c16)
frame_rect(4, 4, 96, 38, 0x3a3a55)
text(8, 8, "LV", 0xffe08a, 1)
text_int(24, 8, h.lvl, 0xffffff, 1)
text(8, 18, "HP", 0x88ff88, 1)
text_int(24, 18, h.hp, 0xffffff, 1)
text(8, 28, "G", 0xffd24a, 1)
text_int(18, 28, reg(R_GOLD), 0xffffff, 1)
text(54, 28, "PO", 0x88ffcc, 1)
text_int(72, 28, reg(R_POTION), 0xffffff, 1)
Screen.fill_rectangle(4, 4, 96, 38, 0x0c0c16)
Screen.draw_rectangle(4, 4, 96, 38, 0x3a3a55)
Screen.draw_text(8, 8, "LV", 0xffe08a, 1)
Screen.draw_number(24, 8, h.lvl, 0xffffff, 1)
Screen.draw_text(8, 18, "HP", 0x88ff88, 1)
Screen.draw_number(24, 18, h.hp, 0xffffff, 1)
Screen.draw_text(8, 28, "G", 0xffd24a, 1)
Screen.draw_number(18, 28, gold, 0xffffff, 1)
Screen.draw_text(54, 28, "PO", 0x88ffcc, 1)
Screen.draw_number(72, 28, potions, 0xffffff, 1)
}
}
}
if m == 1 {
fill_rect(0, 0, 320, 176, 0x241a2e)
Screen.fill_rectangle(0, 0, 320, 176, 0x241a2e)
for (e, a) in query [Stats, Actor, {Enemy}] {
var bs = 5
if reg(R_ETYPE) == 2 { bs = 7 }
if enemy_type == 2 { bs = 7 }
draw_sprite_scaled(a.kind, 160 - bs * 8, 44, bs)
text(100, 20, enemy_name(reg(R_ETYPE)), 0xffffff, 1)
fill_rect(100, 30, 120, 8, 0x401018)
fill_rect(100, 30, e.hp * 120 / e.maxhp, 8, 0xe04040)
Screen.draw_text(100, 20, enemy_name(enemy_type), 0xffffff, 1)
Screen.fill_rectangle(100, 30, 120, 8, 0x401018)
Screen.fill_rectangle(100, 30, e.hp * 120 / e.maxhp, 8, 0xe04040)
}
let ph = reg(R_PHASE)
let ph = turn_phase
var act = 0
if ph >= 2 { act = 1 }
if ph >= 4 { act = 2 }
fill_rect(0, 176, 320, 64, 0x0c0c16)
frame_rect(0, 176, 320, 64, 0x3a3a55)
Screen.fill_rectangle(0, 176, 320, 64, 0x0c0c16)
Screen.draw_rectangle(0, 176, 320, 64, 0x3a3a55)
for (st, pt) in query [Stats, Party] {
let hx = 6 + pt.slot * 92
var spr = 5
if pt.slot == 1 { spr = 9 }
if pt.slot == act { frame_rect(hx - 2, 180, 88, 44, 0xffff00) }
if pt.slot == act { Screen.draw_rectangle(hx - 2, 180, 88, 44, 0xffff00) }
draw_sprite_scaled(spr, hx, 184, 2)
if pt.slot == 0 { text(hx + 36, 182, "KNIGHT", 0xffe08a, 1) }
if pt.slot == 1 { text(hx + 36, 182, "MAGE", 0xc9a0ff, 1) }
text(hx + 36, 195, "HP", 0x88ff88, 1)
text_int(hx + 56, 195, st.hp, 0xffffff, 1)
text(hx + 36, 207, "MP", 0x88aaff, 1)
text_int(hx + 56, 207, st.mp, 0xffffff, 1)
if pt.slot == 0 { Screen.draw_text(hx + 36, 182, "KNIGHT", 0xffe08a, 1) }
if pt.slot == 1 { Screen.draw_text(hx + 36, 182, "MAGE", 0xc9a0ff, 1) }
Screen.draw_text(hx + 36, 195, "HP", 0x88ff88, 1)
Screen.draw_number(hx + 56, 195, st.hp, 0xffffff, 1)
Screen.draw_text(hx + 36, 207, "MP", 0x88aaff, 1)
Screen.draw_number(hx + 56, 207, st.mp, 0xffffff, 1)
}
let cur = reg(R_CUR)
let cur = menu_cursor
if ph == 0 or ph == 1 {
text(206, 181, "P1 KNIGHT", 0xffe08a, 1)
text(214, 192, "ATTACK", 0xffffff, 1)
text(214, 203, "DEFEND", 0xffffff, 1)
text(214, 214, "ITEM", 0xffffff, 1)
text(256, 214, "x", 0x777777, 1)
text_int(264, 214, reg(R_POTION), 0xffd24a, 1)
text(214, 225, "RUN", 0xffffff, 1)
if ph == 0 { text(204, 192 + cur * 11, ">", 0xffff00, 1) }
Screen.draw_text(206, 181, "P1 KNIGHT", 0xffe08a, 1)
Screen.draw_text(214, 192, "ATTACK", 0xffffff, 1)
Screen.draw_text(214, 203, "DEFEND", 0xffffff, 1)
Screen.draw_text(214, 214, "ITEM", 0xffffff, 1)
Screen.draw_text(256, 214, "x", 0x777777, 1)
Screen.draw_number(264, 214, potions, 0xffd24a, 1)
Screen.draw_text(214, 225, "RUN", 0xffffff, 1)
if ph == 0 { Screen.draw_text(204, 192 + cur * 11, ">", 0xffff00, 1) }
}
if ph == 2 or ph == 3 {
text(206, 182, "P2 MAGE", 0xc9a0ff, 1)
text(214, 196, "ATTACK", 0xffffff, 1)
text(214, 208, "HEAL", 0xffffff, 1)
text(214, 220, "DEFEND", 0xffffff, 1)
if ph == 2 { text(204, 196 + cur * 12, ">", 0xffff00, 1) }
Screen.draw_text(206, 182, "P2 MAGE", 0xc9a0ff, 1)
Screen.draw_text(214, 196, "ATTACK", 0xffffff, 1)
Screen.draw_text(214, 208, "HEAL", 0xffffff, 1)
Screen.draw_text(214, 220, "DEFEND", 0xffffff, 1)
if ph == 2 { Screen.draw_text(204, 196 + cur * 12, ">", 0xffff00, 1) }
}
if ph == 4 { text(206, 200, "ENEMY TURN", 0xff8888, 1) }
if ph == 4 { Screen.draw_text(206, 200, "ENEMY TURN", 0xff8888, 1) }
if ph == 1 or ph == 3 {
text(6, 232, "DMG", 0xffff88, 1)
text_int(34, 232, reg(R_PDMG), 0xffffff, 1)
Screen.draw_text(6, 232, "DMG", 0xffff88, 1)
Screen.draw_number(34, 232, player_hit, 0xffffff, 1)
}
if ph == 4 {
text(6, 232, "FOE HITS", 0xff8888, 1)
text_int(66, 232, reg(R_EDMG), 0xffffff, 1)
Screen.draw_text(6, 232, "FOE HITS", 0xff8888, 1)
Screen.draw_number(66, 232, enemy_hit, 0xffffff, 1)
}
}
if m == 2 {
text(112, 104, "YOU FELL", 0xff5555, 2)
text(84, 140, "PRESS ANY KEY", 0xffffff, 1)
Screen.draw_text(112, 104, "YOU FELL", 0xff5555, 2)
Screen.draw_text(84, 140, "PRESS ANY KEY", 0xffffff, 1)
}
if m == 3 {
text(60, 96, "THE RIFT IS SEALED", 0x88ffcc, 2)
text(96, 132, "VICTORY!", 0xffe060, 3)
text(84, 170, "PRESS ANY KEY", 0xffffff, 1)
Screen.draw_text(60, 96, "THE RIFT IS SEALED", 0x88ffcc, 2)
Screen.draw_text(96, 132, "VICTORY!", 0xffe060, 3)
Screen.draw_text(84, 170, "PRESS ANY KEY", 0xffffff, 1)
}
if m == 4 {
fill_rect(60, 60, 200, 120, 0x141422)
frame_rect(60, 60, 200, 120, 0x6a6a95)
text(96, 72, "ITEM SHOP", 0xffe060, 2)
text(80, 104, "BUY POTION", 0xffffff, 1)
text(180, 104, "10 G", 0xffd24a, 1)
text(80, 122, "LEAVE", 0xffffff, 1)
text(70, 104 + reg(R_CUR) * 18, ">", 0xffff00, 1)
text(80, 150, "GOLD", 0xffd24a, 1)
text_int(120, 150, reg(R_GOLD), 0xffffff, 1)
text(160, 150, "POTIONS", 0x88ffcc, 1)
text_int(226, 150, reg(R_POTION), 0xffffff, 1)
Screen.fill_rectangle(60, 60, 200, 120, 0x141422)
Screen.draw_rectangle(60, 60, 200, 120, 0x6a6a95)
Screen.draw_text(96, 72, "ITEM SHOP", 0xffe060, 2)
Screen.draw_text(80, 104, "BUY POTION", 0xffffff, 1)
Screen.draw_text(180, 104, "10 G", 0xffd24a, 1)
Screen.draw_text(80, 122, "LEAVE", 0xffffff, 1)
Screen.draw_text(70, 104 + menu_cursor * 18, ">", 0xffff00, 1)
Screen.draw_text(80, 150, "GOLD", 0xffd24a, 1)
Screen.draw_number(120, 150, gold, 0xffffff, 1)
Screen.draw_text(160, 150, "POTIONS", 0x88ffcc, 1)
Screen.draw_number(226, 150, potions, 0xffffff, 1)
}
present()
Screen.show()
}

View file

@ -25,18 +25,18 @@ handler Boot phase Start {
Party { slot: 1 }
Stats { hp: 26, maxhp: 26, mp: 16, maxmp: 16, atk: 8, def: 4, lvl: 1, xp: 0, guard: 0 }
}
set_reg(R_MODE, 0)
set_reg(R_ENC, 4)
set_reg(R_MAP, 0)
set_reg(R_BOSS, 0)
set_reg(R_GOLD, 20)
set_reg(R_POTION, 2)
game_mode = 0
encounter = 4
world_map = 0
boss_down = 0
gold = 20
potions = 2
}
handler Control phase Input {
if reg(R_MODE) == 0 {
if game_mode == 0 {
for (p) in query [Pos, {Player}] {
let k = key()
let k = Input.key()
var nx = p.x
var ny = p.y
if k == 'w' { ny = p.y - 1 }
@ -52,48 +52,48 @@ handler Control phase Input {
}
}
if moved == 1 {
let tc = tile(p.x, p.y)
let tc = Map.tile(p.x, p.y)
if tc == 'D' {
build_dungeon(0)
p.x = 3
p.y = 2
set_reg(R_MAP, 1)
world_map = 1
}
if tc == 'S' {
build_field(0)
p.x = 36
p.y = 3
set_reg(R_MAP, 0)
world_map = 0
}
if tc == 'B' {
if reg(R_BOSS) == 0 {
set_reg(R_ETYPE, 2)
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 }
}
set_reg(R_MODE, 1)
set_reg(R_PHASE, 0)
set_reg(R_CUR, 0)
game_mode = 1
turn_phase = 0
menu_cursor = 0
}
}
if tc == 'h' {
set_reg(R_MODE, 4)
set_reg(R_CUR, 0)
game_mode = 4
menu_cursor = 0
}
if tc != 'D' {
if tc != 'S' {
if tc != 'B' {
if tc != 'h' {
set_reg(R_ENC, reg(R_ENC) - 1)
if reg(R_ENC) <= 0 {
set_reg(R_ENC, rng_range(4, 9))
encounter = encounter - 1
if encounter <= 0 {
encounter = Random.range(4, 9)
var et = 0
if reg(R_MAP) == 1 { et = 1 }
if reg(R_MAP) == 0 {
if rng_chance(40) { et = 1 }
if world_map == 1 { et = 1 }
if world_map == 0 {
if Random.chance(40) { et = 1 }
}
set_reg(R_ETYPE, et)
enemy_type = et
if et == 0 {
spawn Enemy {
Actor { kind: 6 }
@ -106,9 +106,9 @@ handler Control phase Input {
Stats { hp: 30, maxhp: 30, mp: 0, maxmp: 0, atk: 11, def: 5, lvl: 1, xp: 15, guard: 0 }
}
}
set_reg(R_MODE, 1)
set_reg(R_PHASE, 0)
set_reg(R_CUR, 0)
game_mode = 1
turn_phase = 0
menu_cursor = 0
}
}
}
@ -123,18 +123,18 @@ handler Control phase Input {
# shop (at the house 'h' tile): buy potions with gold
handler Shop phase Update {
if reg(R_MODE) == 4 {
let k = key()
if k == 'w' { set_reg(R_CUR, max(0, reg(R_CUR) - 1)) }
if k == 's' { set_reg(R_CUR, min(1, reg(R_CUR) + 1)) }
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 reg(R_CUR) == 0 {
if reg(R_GOLD) >= 10 {
set_reg(R_GOLD, reg(R_GOLD) - 10)
set_reg(R_POTION, reg(R_POTION) + 1)
if menu_cursor == 0 {
if gold >= 10 {
gold = gold - 10
potions = potions + 1
}
}
if reg(R_CUR) == 1 { set_reg(R_MODE, 0) }
if menu_cursor == 1 { game_mode = 0 }
}
}
}

View file

@ -12,7 +12,7 @@ fn tile_sprite(c: int) -> int {
return SPR_GRASS
}
fn walkable(x: int, y: int) -> bool {
let c = tile(x, y)
let c = Map.tile(x, y)
return c == '.' or c == 'D' or c == 'r' or c == ',' or c == 'S' or c == 'B' or c == 'h'
}
fn is_confirm(k: int) -> bool { return k == 32 or k == 10 or k == 13 }
@ -23,47 +23,47 @@ fn enemy_name(et: int) -> str {
}
fn build_field(x: int) -> int {
map_size(40, 18)
map_row(0, "########################################")
map_row(1, "#......................................#")
map_row(2, "#...TT.........................TT.....D#")
map_row(3, "#..TT.......................TT.........#")
map_row(4, "#..T.........................T.........#")
map_row(5, "#....................................T.#")
map_row(6, "#.....TT....................TT.......T.#")
map_row(7, "#....TT.....................T..........#")
map_row(8, "#...........rrrrrrrr........HH.........#")
map_row(9, "#..........r........r.......HH.........#")
map_row(10, "#......TT...r........rrrrrrrrhr......T.#")
map_row(11, "#.....TT...r.................r.......T.#")
map_row(12, "#..........r.......TT.......r..........#")
map_row(13, "#..........rrrrrrrrrrrrrrrrr.........T.#")
map_row(14, "#.........TT.........................T.#")
map_row(15, "#........TT..........................T.#")
map_row(16, "#....................................T.#")
map_row(17, "########################################")
Map.size(40, 18)
Map.row(0, "########################################")
Map.row(1, "#......................................#")
Map.row(2, "#...TT.........................TT.....D#")
Map.row(3, "#..TT.......................TT.........#")
Map.row(4, "#..T.........................T.........#")
Map.row(5, "#....................................T.#")
Map.row(6, "#.....TT....................TT.......T.#")
Map.row(7, "#....TT.....................T..........#")
Map.row(8, "#...........rrrrrrrr........HH.........#")
Map.row(9, "#..........r........r.......HH.........#")
Map.row(10, "#......TT...r........rrrrrrrrhr......T.#")
Map.row(11, "#.....TT...r.................r.......T.#")
Map.row(12, "#..........r.......TT.......r..........#")
Map.row(13, "#..........rrrrrrrrrrrrrrrrr.........T.#")
Map.row(14, "#.........TT.........................T.#")
Map.row(15, "#........TT..........................T.#")
Map.row(16, "#....................................T.#")
Map.row(17, "########################################")
return 0
}
fn build_dungeon(x: int) -> int {
map_size(40, 18)
map_row(0, "========================================")
map_row(1, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(2, "=,S,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(3, "=,,,,,====,,,,,,,,,,,,,,,====,,,,,,,,,,=")
map_row(4, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(5, "=,,,,,,,,,,,,,====,,,,,,,,,,,,,,,,,,,,,=")
map_row(6, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,====,,,,,=")
map_row(7, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(8, "=,,,====,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(9, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(10, "=,,,,,,,,,,,,,,,,,,====,,,,,,,,,,,,,,,,=")
map_row(11, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(12, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,====,,,,,,,=")
map_row(13, "=,,,,,,,,,====,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(14, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(15, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,B,,=")
map_row(16, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
map_row(17, "========================================")
Map.size(40, 18)
Map.row(0, "========================================")
Map.row(1, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(2, "=,S,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(3, "=,,,,,====,,,,,,,,,,,,,,,====,,,,,,,,,,=")
Map.row(4, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(5, "=,,,,,,,,,,,,,====,,,,,,,,,,,,,,,,,,,,,=")
Map.row(6, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,====,,,,,=")
Map.row(7, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(8, "=,,,====,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(9, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(10, "=,,,,,,,,,,,,,,,,,,====,,,,,,,,,,,,,,,,=")
Map.row(11, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(12, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,====,,,,,,,=")
Map.row(13, "=,,,,,,,,,====,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(14, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(15, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,B,,=")
Map.row(16, "=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,=")
Map.row(17, "========================================")
return 0
}

View file

@ -29,15 +29,15 @@ const SPR_MAGE: int = 9
const SPR_FLOOR: int = 10
const SPR_WALL: int = 11
const R_MODE: int = 0 # 0 field, 1 battle, 2 gameover, 3 victory
const R_PHASE: int = 1
const R_CUR: int = 2
const R_ENC: int = 3
const R_ETYPE: int = 4 # 0 slime, 1 skeleton, 2 boss
const R_PDMG: int = 5
const R_EDMG: int = 6
const R_GOLD: int = 7
const R_MAP: int = 8 # 0 overworld, 1 dungeon
const R_BOSS: int = 9 # boss defeated flag
const R_ACK: int = 10 # debounce for end screens
const R_POTION: int = 11 # potions in inventory
var game_mode: int = 0 # 0 field, 1 battle, 2 gameover, 3 victory
var turn_phase: int = 0
var menu_cursor: int = 0
var encounter: int = 0
var enemy_type: int = 0 # 0 slime, 1 skeleton, 2 boss
var player_hit: int = 0
var enemy_hit: int = 0
var gold: int = 0
var world_map: int = 0 # 0 overworld, 1 dungeon
var boss_down: int = 0 # boss defeated flag
var ack: int = 0 # debounce for end screens
var potions: int = 0 # potions in inventory