2023-01-12 20:33:50 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/flow"
|
2023-02-02 06:48:16 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
2023-01-12 20:33:50 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
2023-03-16 05:14:39 +00:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-03-16 18:22:56 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
2023-01-12 20:33:50 +00:00
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
|
|
|
window, _ := tomo.NewWindow(2, 2)
|
|
|
|
window.SetTitle("adventure")
|
2023-03-16 18:22:56 +00:00
|
|
|
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
2023-01-12 20:33:50 +00:00
|
|
|
window.Adopt(container)
|
|
|
|
|
|
|
|
var world flow.Flow
|
|
|
|
world.Transition = container.DisownAll
|
|
|
|
world.Stages = map [string] func () {
|
|
|
|
"start": func () {
|
2023-02-02 06:48:16 +00:00
|
|
|
label := basicElements.NewLabel (
|
2023-01-16 23:04:41 +00:00
|
|
|
"you are standing next to a river.", true)
|
2023-01-12 20:33:50 +00:00
|
|
|
|
2023-02-02 06:48:16 +00:00
|
|
|
button0 := basicElements.NewButton("go in the river")
|
2023-01-12 20:33:50 +00:00
|
|
|
button0.OnClick(world.SwitchFunc("wet"))
|
2023-02-02 06:48:16 +00:00
|
|
|
button1 := basicElements.NewButton("walk along the river")
|
2023-01-12 20:33:50 +00:00
|
|
|
button1.OnClick(world.SwitchFunc("house"))
|
2023-02-02 06:48:16 +00:00
|
|
|
button2 := basicElements.NewButton("turn around")
|
2023-01-12 20:33:50 +00:00
|
|
|
button2.OnClick(world.SwitchFunc("bear"))
|
2023-01-12 21:02:33 +00:00
|
|
|
|
|
|
|
container.Warp ( func () {
|
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
container.Adopt(button1, false)
|
|
|
|
container.Adopt(button2, false)
|
2023-01-30 22:25:09 +00:00
|
|
|
button0.Focus()
|
2023-01-12 21:02:33 +00:00
|
|
|
})
|
2023-01-12 20:33:50 +00:00
|
|
|
},
|
|
|
|
"wet": func () {
|
2023-02-02 06:48:16 +00:00
|
|
|
label := basicElements.NewLabel (
|
2023-01-12 20:33:50 +00:00
|
|
|
"you get completely soaked.\n" +
|
2023-01-16 23:04:41 +00:00
|
|
|
"you die of hypothermia.", true)
|
2023-01-12 20:33:50 +00:00
|
|
|
|
2023-02-02 06:48:16 +00:00
|
|
|
button0 := basicElements.NewButton("try again")
|
2023-01-12 20:33:50 +00:00
|
|
|
button0.OnClick(world.SwitchFunc("start"))
|
2023-02-02 06:48:16 +00:00
|
|
|
button1 := basicElements.NewButton("exit")
|
2023-01-12 20:33:50 +00:00
|
|
|
button1.OnClick(tomo.Stop)
|
2023-01-12 21:02:33 +00:00
|
|
|
|
|
|
|
container.Warp (func () {
|
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
container.Adopt(button1, false)
|
2023-01-30 22:25:09 +00:00
|
|
|
button0.Focus()
|
2023-01-12 21:02:33 +00:00
|
|
|
})
|
2023-01-12 20:33:50 +00:00
|
|
|
},
|
|
|
|
"house": func () {
|
2023-02-02 06:48:16 +00:00
|
|
|
label := basicElements.NewLabel (
|
2023-01-12 20:33:50 +00:00
|
|
|
"you are standing in front of a delapidated " +
|
2023-01-16 23:04:41 +00:00
|
|
|
"house.", true)
|
2023-01-12 20:33:50 +00:00
|
|
|
|
2023-02-02 06:48:16 +00:00
|
|
|
button1 := basicElements.NewButton("go inside")
|
2023-01-12 20:33:50 +00:00
|
|
|
button1.OnClick(world.SwitchFunc("inside"))
|
2023-02-02 06:48:16 +00:00
|
|
|
button0 := basicElements.NewButton("turn back")
|
2023-01-12 20:33:50 +00:00
|
|
|
button0.OnClick(world.SwitchFunc("start"))
|
2023-01-12 21:02:33 +00:00
|
|
|
|
|
|
|
container.Warp (func () {
|
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button1, false)
|
|
|
|
container.Adopt(button0, false)
|
2023-01-30 22:25:09 +00:00
|
|
|
button1.Focus()
|
2023-01-12 21:02:33 +00:00
|
|
|
})
|
2023-01-12 20:33:50 +00:00
|
|
|
},
|
|
|
|
"inside": func () {
|
2023-02-02 06:48:16 +00:00
|
|
|
label := basicElements.NewLabel (
|
2023-01-12 20:33:50 +00:00
|
|
|
"you are standing inside of the house.\n" +
|
|
|
|
"it is dark, but rays of light stream " +
|
|
|
|
"through the window.\n" +
|
|
|
|
"there is nothing particularly interesting " +
|
2023-01-16 23:04:41 +00:00
|
|
|
"here.", true)
|
2023-01-12 20:33:50 +00:00
|
|
|
|
2023-02-02 06:48:16 +00:00
|
|
|
button0 := basicElements.NewButton("go back outside")
|
2023-01-12 20:33:50 +00:00
|
|
|
button0.OnClick(world.SwitchFunc("house"))
|
2023-01-12 21:02:33 +00:00
|
|
|
|
|
|
|
container.Warp (func () {
|
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
2023-01-30 22:25:09 +00:00
|
|
|
button0.Focus()
|
2023-01-12 21:02:33 +00:00
|
|
|
})
|
2023-01-12 20:33:50 +00:00
|
|
|
},
|
|
|
|
"bear": func () {
|
2023-02-02 06:48:16 +00:00
|
|
|
label := basicElements.NewLabel (
|
2023-01-12 20:33:50 +00:00
|
|
|
"you come face to face with a bear.\n" +
|
2023-01-16 23:04:41 +00:00
|
|
|
"it eats you (it was hungry).", true)
|
2023-01-12 20:33:50 +00:00
|
|
|
|
2023-02-02 06:48:16 +00:00
|
|
|
button0 := basicElements.NewButton("try again")
|
2023-01-12 20:33:50 +00:00
|
|
|
button0.OnClick(world.SwitchFunc("start"))
|
2023-02-02 06:48:16 +00:00
|
|
|
button1 := basicElements.NewButton("exit")
|
2023-01-12 20:33:50 +00:00
|
|
|
button1.OnClick(tomo.Stop)
|
2023-01-12 21:02:33 +00:00
|
|
|
|
|
|
|
container.Warp (func () {
|
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
container.Adopt(button1, false)
|
2023-01-30 22:25:09 +00:00
|
|
|
button0.Focus()
|
2023-01-12 21:02:33 +00:00
|
|
|
})
|
2023-01-12 20:33:50 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
world.Switch("start")
|
|
|
|
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
}
|