2023-02-19 23:52:50 -07:00
|
|
|
package main
|
|
|
|
|
2023-02-21 14:48:56 -07:00
|
|
|
import "bytes"
|
|
|
|
import _ "embed"
|
|
|
|
import _ "image/png"
|
2023-02-19 23:52:50 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo"
|
2023-02-21 16:53:19 -07:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
2023-03-30 21:19:04 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
2023-03-15 23:14:39 -06:00
|
|
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
2023-03-16 12:22:56 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
2023-02-19 23:52:50 -07:00
|
|
|
|
2023-02-21 14:48:56 -07:00
|
|
|
//go:embed wall.png
|
|
|
|
var wallTextureBytes []uint8
|
|
|
|
|
2023-02-19 23:52:50 -07:00
|
|
|
func main () {
|
|
|
|
tomo.Run(run)
|
|
|
|
}
|
|
|
|
|
|
|
|
func run () {
|
|
|
|
window, _ := tomo.NewWindow(640, 480)
|
|
|
|
window.SetTitle("Raycaster")
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
container := containers.NewContainer(layouts.Vertical { false, false })
|
2023-02-19 23:52:50 -07:00
|
|
|
window.Adopt(container)
|
|
|
|
|
2023-02-21 14:48:56 -07:00
|
|
|
wallTexture, _ := TextureFrom(bytes.NewReader(wallTextureBytes))
|
|
|
|
|
|
|
|
game := NewGame (World {
|
2023-02-19 23:52:50 -07:00
|
|
|
Data: []int {
|
2023-02-21 14:48:56 -07: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-19 23:52:50 -07:00
|
|
|
},
|
2023-02-21 14:48:56 -07:00
|
|
|
Stride: 13,
|
|
|
|
}, Textures {
|
|
|
|
wallTexture,
|
2023-02-19 23:52:50 -07:00
|
|
|
})
|
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
topBar := containers.NewContainer(layouts.Horizontal { true, true })
|
|
|
|
staminaBar := elements.NewProgressBar(game.Stamina())
|
|
|
|
healthBar := elements.NewProgressBar(game.Health())
|
2023-02-21 16:53:19 -07:00
|
|
|
|
2023-03-30 21:19:04 -06:00
|
|
|
topBar.Adopt(elements.NewLabel("Stamina:", false), false)
|
2023-02-21 16:53:19 -07:00
|
|
|
topBar.Adopt(staminaBar, true)
|
2023-03-30 21:19:04 -06:00
|
|
|
topBar.Adopt(elements.NewLabel("Health:", false), false)
|
2023-02-21 16:53:19 -07:00
|
|
|
topBar.Adopt(healthBar, true)
|
|
|
|
container.Adopt(topBar, false)
|
2023-02-19 23:52:50 -07:00
|
|
|
container.Adopt(game, true)
|
|
|
|
game.Focus()
|
2023-02-21 16:53:19 -07:00
|
|
|
|
|
|
|
game.OnStatUpdate (func () {
|
|
|
|
staminaBar.SetProgress(game.Stamina())
|
|
|
|
})
|
2023-02-19 23:52:50 -07:00
|
|
|
|
|
|
|
window.OnClose(tomo.Stop)
|
|
|
|
window.Show()
|
2023-02-21 16:53:19 -07:00
|
|
|
|
|
|
|
popups.NewDialog (
|
|
|
|
popups.DialogKindInfo,
|
2023-03-30 21:19:04 -06:00
|
|
|
window,
|
2023-02-21 16:53:19 -07: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-19 23:52:50 -07:00
|
|
|
}
|