forked from haneda3/inovation5
-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.go
61 lines (52 loc) · 1.14 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
package main
import (
"flag"
"fmt"
"os"
"runtime/pprof"
"runtime/trace"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/go-inovation/ino"
)
var (
memProfile = flag.String("memprofile", "", "write memory profile to file")
traceOut = flag.String("trace", "", "write trace to file")
transparent = flag.Bool("transparent", false, "background transparency")
)
func main() {
flag.Parse()
if *traceOut != "" {
f, err := os.Create(*traceOut)
if err != nil {
panic(err)
}
defer f.Close()
trace.Start(f)
defer trace.Stop()
}
game, err := ino.NewGame()
if err != nil {
panic(err)
}
if *transparent {
ebiten.SetScreenTransparent(true)
ebiten.SetWindowDecorated(false)
game.SetTransparent()
}
const scale = 2
ebiten.SetWindowSize(ino.ScreenWidth*scale, ino.ScreenHeight*scale)
ebiten.SetWindowResizable(true)
if err := ebiten.RunGame(game); err != nil {
panic(err)
}
if *memProfile != "" {
f, err := os.Create(*memProfile)
if err != nil {
panic(err)
}
defer f.Close()
if err := pprof.WriteHeapProfile(f); err != nil {
panic(fmt.Sprintf("could not write memory profile: %s", err))
}
}
}