-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuiInput.go
55 lines (43 loc) · 1022 Bytes
/
uiInput.go
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
52
53
54
55
package main
import (
"log"
"time"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
)
func (g *Game) Update() error {
if !gameLoaded.Load() {
return nil
}
if !ebiten.IsFocused() {
return nil
}
mx, my := ebiten.CursorPosition()
lmb := inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft)
//mmb := inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonMiddle)
//rmb := inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight)
if gameMode.Load() == MODE_SPLASH {
for b, button := range splashButtons {
if mx >= button.topLeft.X &&
mx <= button.bottomRight.X &&
my >= button.topLeft.Y &&
my <= button.bottomRight.Y {
if lmb {
log.Printf("Click: %v", button.name)
splashButtons[b].clicked = time.Now()
go func() {
time.Sleep(flashSpeed)
button.action()
}()
break
} else {
splashButtons[b].hover = true
break
}
} else {
splashButtons[b].hover = false
}
}
}
return nil
}