2023-02-20 06:52:50 +00:00
|
|
|
package main
|
|
|
|
|
2023-02-21 21:48:56 +00:00
|
|
|
import "bytes"
|
|
|
|
import _ "embed"
|
|
|
|
import _ "image/png"
|
2023-02-20 06:52:50 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
2023-02-21 23:53:19 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
2023-03-31 03:19:04 +00:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
2023-03-16 05:14:39 +00:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-02-20 06:52:50 +00:00
|
|
|
|
2023-02-21 21:48:56 +00:00
|
|
|
//go:embed wall.png
|
|
|
|
var wallTextureBytes []uint8
|
|
|
|
|
2023-02-20 06:52:50 +00:00
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
2023-04-16 02:23:08 +00:00
|
|
|
// FIXME this entire example seems to be broken
|
|
|
|
|
2023-02-20 06:52:50 +00:00
|
|
|
func run () {
|
2023-04-10 06:58:52 +00:00
|
|
|
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 640, 480))
|
2023-02-20 06:52:50 +00:00
|
|
|
window.SetTitle("Raycaster")
|
|
|
|
|
2023-04-18 20:18:30 +00:00
|
|
|
container := elements.NewVBox(elements.SpaceNone)
|
2023-02-20 06:52:50 +00:00
|
|
|
window.Adopt(container)
|
|
|
|
|
2023-02-21 21:48:56 +00:00
|
|
|
wallTexture, _ := TextureFrom(bytes.NewReader(wallTextureBytes))
|
|
|
|
|
|
|
|
game := NewGame (World {
|
2023-02-20 06:52:50 +00:00
|
|
|
Data: []int {
|
2023-02-21 21:48:56 +00:00
|
|
|
1,1,1,1,1,1,1,1,1,1,1,1,1,
|
|
|
|
1,0,0,0,0,0,0,0,0,0,0,0,1,
|
|
|
|
1,0,1,1,1,1,1,1,1,0,0,0,1,
|
|
|
|
1,0,0,0,0,0,0,0,1,1,1,0,1,
|
|
|
|
1,0,0,0,0,0,0,0,1,0,0,0,1,
|
|
|
|
1,0,0,0,0,0,0,0,1,0,1,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,1,0,0,0,1,
|
|
|
|
1,0,0,0,0,0,0,0,1,1,0,1,1,
|
|
|
|
1,0,0,1,0,0,0,0,0,0,0,0,1,
|
|
|
|
1,0,1,1,1,0,0,0,0,0,0,0,1,
|
|
|
|
1,0,0,1,0,0,0,0,0,0,0,0,1,
|
|
|
|
1,0,0,0,0,0,0,0,0,0,0,0,1,
|
|
|
|
1,0,0,0,0,1,0,0,0,0,0,0,1,
|
|
|
|
1,1,1,1,1,1,1,1,1,1,1,1,1,
|
2023-02-20 06:52:50 +00:00
|
|
|
},
|
2023-02-21 21:48:56 +00:00
|
|
|
Stride: 13,
|
|
|
|
}, Textures {
|
|
|
|
wallTexture,
|
2023-02-20 06:52:50 +00:00
|
|
|
})
|
|
|
|
|
2023-04-18 20:18:30 +00:00
|
|
|
topBar := elements.NewHBox(elements.SpaceBoth)
|
2023-03-31 03:19:04 +00:00
|
|
|
staminaBar := elements.NewProgressBar(game.Stamina())
|
|
|
|
healthBar := elements.NewProgressBar(game.Health())
|
2023-02-21 23:53:19 +00:00
|
|
|
|
2023-04-18 20:18:30 +00:00
|
|
|
topBar.Adopt(elements.NewLabel("Stamina:"))
|
|
|
|
topBar.AdoptExpand(staminaBar)
|
|
|
|
topBar.Adopt(elements.NewLabel("Health:"))
|
|
|
|
topBar.AdoptExpand(healthBar)
|
|
|
|
container.Adopt(topBar)
|
2023-04-20 04:22:29 +00:00
|
|
|
container.AdoptExpand(game.Raycaster)
|
2023-02-20 06:52:50 +00:00
|
|
|
game.Focus()
|
2023-02-21 23:53:19 +00:00
|
|
|
|
|
|
|
game.OnStatUpdate (func () {
|
|
|
|
staminaBar.SetProgress(game.Stamina())
|
|
|
|
})
|
2023-04-20 04:22:29 +00:00
|
|
|
game.Start()
|
2023-02-20 06:52:50 +00:00
|
|
|
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
2023-02-21 23:53:19 +00:00
|
|
|
|
|
|
|
popups.NewDialog (
|
|
|
|
popups.DialogKindInfo,
|
2023-03-31 03:19:04 +00:00
|
|
|
window,
|
2023-02-21 23:53:19 +00:00
|
|
|
"Welcome to the backrooms",
|
|
|
|
"You've no-clipped into the backrooms!\n" +
|
|
|
|
"Move with WASD, and look with the arrow keys.\n" +
|
|
|
|
"Keep an eye on your health and stamina.")
|
2023-02-20 06:52:50 +00:00
|
|
|
}
|