2023-01-12 13:33:50 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/flow"
|
2023-03-30 21:19:04 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
2023-03-15 23:14:39 -06:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-01-12 13:33:50 -07:00
|
|
|
|
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
2023-04-10 00:58:52 -06:00
|
|
|
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 192, 192))
|
2023-01-12 13:33:50 -07:00
|
|
|
window.SetTitle("adventure")
|
2023-04-16 15:30:13 -06:00
|
|
|
container := elements.NewVBox(true, true)
|
2023-01-12 13:33:50 -07:00
|
|
|
window.Adopt(container)
|
|
|
|
|
|
|
|
var world flow.Flow
|
|
|
|
world.Transition = container.DisownAll
|
|
|
|
world.Stages = map [string] func () {
|
|
|
|
"start": func () {
|
2023-03-30 21:19:04 -06:00
|
|
|
label := elements.NewLabel (
|
2023-01-16 16:04:41 -07:00
|
|
|
"you are standing next to a river.", true)
|
2023-01-12 13:33:50 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
button0 := elements.NewButton("go in the river")
|
2023-01-12 13:33:50 -07:00
|
|
|
button0.OnClick(world.SwitchFunc("wet"))
|
2023-03-30 21:19:04 -06:00
|
|
|
button1 := elements.NewButton("walk along the river")
|
2023-01-12 13:33:50 -07:00
|
|
|
button1.OnClick(world.SwitchFunc("house"))
|
2023-03-30 21:19:04 -06:00
|
|
|
button2 := elements.NewButton("turn around")
|
2023-01-12 13:33:50 -07:00
|
|
|
button2.OnClick(world.SwitchFunc("bear"))
|
2023-01-12 14:02:33 -07:00
|
|
|
|
2023-04-15 20:23:08 -06:00
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
container.Adopt(button1, false)
|
|
|
|
container.Adopt(button2, false)
|
|
|
|
button0.Focus()
|
2023-01-12 13:33:50 -07:00
|
|
|
},
|
|
|
|
"wet": func () {
|
2023-03-30 21:19:04 -06:00
|
|
|
label := elements.NewLabel (
|
2023-01-12 13:33:50 -07:00
|
|
|
"you get completely soaked.\n" +
|
2023-01-16 16:04:41 -07:00
|
|
|
"you die of hypothermia.", true)
|
2023-01-12 13:33:50 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
button0 := elements.NewButton("try again")
|
2023-01-12 13:33:50 -07:00
|
|
|
button0.OnClick(world.SwitchFunc("start"))
|
2023-03-30 21:19:04 -06:00
|
|
|
button1 := elements.NewButton("exit")
|
2023-01-12 13:33:50 -07:00
|
|
|
button1.OnClick(tomo.Stop)
|
2023-01-12 14:02:33 -07:00
|
|
|
|
2023-04-15 20:23:08 -06:00
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
container.Adopt(button1, false)
|
|
|
|
button0.Focus()
|
2023-01-12 13:33:50 -07:00
|
|
|
},
|
|
|
|
"house": func () {
|
2023-03-30 21:19:04 -06:00
|
|
|
label := elements.NewLabel (
|
2023-01-12 13:33:50 -07:00
|
|
|
"you are standing in front of a delapidated " +
|
2023-01-16 16:04:41 -07:00
|
|
|
"house.", true)
|
2023-01-12 13:33:50 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
button1 := elements.NewButton("go inside")
|
2023-01-12 13:33:50 -07:00
|
|
|
button1.OnClick(world.SwitchFunc("inside"))
|
2023-03-30 21:19:04 -06:00
|
|
|
button0 := elements.NewButton("turn back")
|
2023-01-12 13:33:50 -07:00
|
|
|
button0.OnClick(world.SwitchFunc("start"))
|
2023-01-12 14:02:33 -07:00
|
|
|
|
2023-04-15 20:23:08 -06:00
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button1, false)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
button1.Focus()
|
2023-01-12 13:33:50 -07:00
|
|
|
},
|
|
|
|
"inside": func () {
|
2023-03-30 21:19:04 -06:00
|
|
|
label := elements.NewLabel (
|
2023-01-12 13:33:50 -07: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 16:04:41 -07:00
|
|
|
"here.", true)
|
2023-01-12 13:33:50 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
button0 := elements.NewButton("go back outside")
|
2023-01-12 13:33:50 -07:00
|
|
|
button0.OnClick(world.SwitchFunc("house"))
|
2023-01-12 14:02:33 -07:00
|
|
|
|
2023-04-15 20:23:08 -06:00
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
button0.Focus()
|
2023-01-12 13:33:50 -07:00
|
|
|
},
|
|
|
|
"bear": func () {
|
2023-03-30 21:19:04 -06:00
|
|
|
label := elements.NewLabel (
|
2023-01-12 13:33:50 -07:00
|
|
|
"you come face to face with a bear.\n" +
|
2023-01-16 16:04:41 -07:00
|
|
|
"it eats you (it was hungry).", true)
|
2023-01-12 13:33:50 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
button0 := elements.NewButton("try again")
|
2023-01-12 13:33:50 -07:00
|
|
|
button0.OnClick(world.SwitchFunc("start"))
|
2023-03-30 21:19:04 -06:00
|
|
|
button1 := elements.NewButton("exit")
|
2023-01-12 13:33:50 -07:00
|
|
|
button1.OnClick(tomo.Stop)
|
2023-01-12 14:02:33 -07:00
|
|
|
|
2023-04-15 20:23:08 -06:00
|
|
|
container.Adopt(label, true)
|
|
|
|
container.Adopt(button0, false)
|
|
|
|
container.Adopt(button1, false)
|
|
|
|
button0.Focus()
|
2023-01-12 13:33:50 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
world.Switch("start")
|
|
|
|
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
|
|
|
}
|