This repository was archived by the owner on Sep 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
72 lines (60 loc) · 1.24 KB
/
main.go
File metadata and controls
72 lines (60 loc) · 1.24 KB
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
package main
import (
"flag"
"log"
"os"
"runtime/pprof"
"candy/assets"
"candy/graphics"
"candy/observability"
"candy/screen"
"github.com/hajimehoshi/ebiten/v2"
)
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
var memprofile = flag.String("memprofile", "", "write memory profile to this file")
func main() {
flag.Parse()
// Enable CPU profiling
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
defer f.Close()
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
// Enable memory profiling
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
log.Fatal(err)
}
defer f.Close()
pprof.WriteHeapProfile(f)
return
}
eb := graphics.NewEbiten(true, true)
ass, err := assets.LoadAssets("public")
if err != nil {
panic(err)
}
logger := observability.NewLogger(observability.Info)
app, err := screen.NewApp(&logger, ass, &eb)
if err != nil {
panic(err)
}
err = app.Launch()
if err != nil {
panic(err)
}
g := graphics.NewEbitenWindow(&graphics.WindowConfig{
Width: screen.Width,
Height: screen.Height,
Title: "Candy",
}, app, 24, &eb)
g.Init()
if err := ebiten.RunGame(g); err != nil {
log.Fatal(err)
}
}