1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package main
import (
"image/color"
"time"
"github.com/hajimehoshi/ebiten/v2"
"muhq.space/muhqs-game/go/font"
"muhq.space/muhqs-game/go/ui"
)
type app struct {
ui.Collection
windowWidth int
windowHeight int
}
func (a *app) Update() error {
if a.Widgets() == nil {
a.build()
}
if err := ui.Update(); err != nil {
return err
}
return a.Collection.Update()
}
func (a *app) build() {
tI := ui.NewTextInput(100, 100, 200, 200, "i", false)
tI.Bg(color.White).Fg(color.Black).Centering(true)
a.AddWidget(tI)
a.AddWidget(ui.NewTimerBar(0, 10, a.windowWidth, 5, 30*time.Second))
a.AddWidget(ui.NewSpinner(100, 400, 50))
}
func (a *app) Layout(width, height int) (int, int) {
return a.windowWidth, a.windowHeight
}
func main() {
font.InitFont()
app := &app{windowWidth: 800, windowHeight: 1000}
ebiten.SetWindowSize(app.windowWidth, app.windowHeight)
ebiten.SetWindowTitle("Muhq's Game")
_ = ebiten.RunGame(app)
}
|