ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.3 KiB
Text
31 lines
1.3 KiB
Text
# scene_menus.ludic — scenes: `become` from an @On listener, @Queries handlers inside
|
|
# a layer, `scene X shows Menu` (opened / closed by the engine), `lasts N then Y`,
|
|
# `goto:` buttons, and scene-qualified handler names. Keys drive frames. Prints:
|
|
# 100 200 201 1 202 300 6 7 8
|
|
program SceneMenus {
|
|
import "ludic.core/components.ludic"
|
|
property Pos { x: int = 0 }
|
|
model Thing { Pos }
|
|
let menu_font: int = 0
|
|
state SceneMenusState {
|
|
frames: int = 0
|
|
}
|
|
ui Menu {
|
|
panel id: Root w: 100 pad: 4 bg: Color.Gunmetal border: Color.SlateGray align: center {
|
|
button id: Go text: "Go" font: menu_font size: 16 w: 80 goto: Play
|
|
}
|
|
}
|
|
scene Splash start lasts 1 then Title { on enter { print(100) } }
|
|
scene Title shows Menu {
|
|
on enter { print(200) }
|
|
on exit { print(202) }
|
|
layer L { handler Tick(scene_menus_st: mut SceneMenusState) phase Update { scene_menus_st.frames += 1; if scene_menus_st.frames == 1 { print(201); emit UiClicked(id: UI_Go) } } }
|
|
}
|
|
@On(UiClicked) handler Report { print(id) } # UI_Go is widget 1 (the root panel is 0)
|
|
scene Play {
|
|
on enter { print(300); spawn Thing { Pos { x: 5 } } }
|
|
layer Sim {
|
|
@Queries(these: [Pos]) handler Tick phase Update { Pos.x += 1; print(Pos.x); if Pos.x >= 8 { quit() } }
|
|
}
|
|
}
|
|
}
|