forked from mentaman/PirateLand
/
main.go
72 lines (61 loc) · 1.13 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
package main
import (
"flag"
"fmt"
"github.com/mentaman/PirateLand/Game/Scenes"
"github.com/vova616/garageEngine/engine"
//"math"
//"github.com/go-gl/gl"
"os"
//"runtime"
"runtime/pprof"
//"time"
)
var cpuprofile = flag.String("p", "", "write cpu profile to file")
var memprofile = flag.String("m", "", "write mem profile to file")
//
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
fmt.Errorf("%s\n", err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
file, _ := os.Create("./log.txt")
os.Stdout = file
os.Stderr = file
os.Stdin = file
defer file.Close()
go Start()
engine.Terminated()
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
fmt.Errorf("%s\n", err)
}
pprof.WriteHeapProfile(f)
f.Close()
return
}
}
//
func Start() {
defer func() {
if p := recover(); p != nil {
fmt.Println(p, engine.PanicPath())
}
engine.Terminate()
}()
engine.StartEngine()
_ = Game.MenuSceneG
/*
Running local server.
*/
//go Server.StartServer()
engine.LoadScene(Game.MenuSceneG)
for engine.MainLoop() {
}
}