-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
81 lines (68 loc) · 1.47 KB
/
main.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
_ "image/png"
"log"
"github.com/hajimehoshi/ebiten"
"github.com/tkido/tendon/ui"
)
const (
screenWidth = 640
screenHeight = 480
)
var (
game Game
root *ui.Box
count int
)
// Game is status of game
type Game struct {
IsDebugPrint bool
}
func init() {
game = Game{false}
root = ui.NewRoot(screenWidth, screenHeight, ui.Color("0f0"))
menu := menuScreen()
// menu := mouseScreen()
mainMenu := mainMenu()
root.Add(0, 0, mainMenu)
root.Add(0, 0, menu)
root.SetKeyCallback(ebiten.KeyF4, func(el ui.Element) {
game.IsDebugPrint = !game.IsDebugPrint
})
root.SetKeyCallback(ebiten.KeyF5, func(el ui.Element) {
ebiten.SetScreenScale(2)
})
root.SetMouseCallback(ui.LeftClick, func(el ui.Element) {
log.Println("Foobar!!")
})
menu.SetKeyCallback(ebiten.KeyF5, func(el ui.Element) {
x, y := el.Position()
el.Move(x+10, y+10)
})
menu.SetFocus()
}
func (game *Game) Update(screen *ebiten.Image) error {
return ui.Update()
}
func (game *Game) Draw(screen *ebiten.Image) {
ui.Draw(screen)
if game.IsDebugPrint {
err := debugPrint(screen)
if err != nil {
return
}
}
return
}
func (game *Game) Layout(outsideWidth, outsideHeight int) (width, height int) {
return screenWidth, screenHeight
}
func main() {
ebiten.SetWindowSize(screenWidth, screenHeight)
ebiten.SetWindowTitle("Charactor Generator")
ebiten.SetRunnableInBackground(true)
ebiten.SetWindowFloating(true)
if err := ebiten.RunGame(&game); err != nil {
log.Fatal(err)
}
}