forked from vova616/GarageEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
93 lines (79 loc) · 1.74 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
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"flag"
"fmt"
"github.com/vova616/GarageEngine/engine"
"github.com/vova616/GarageEngine/engine/input"
"github.com/vova616/GarageEngine/networkOnline"
"github.com/vova616/GarageEngine/spaceCookies/game"
"github.com/vova616/GarageEngine/spaceCookies/login"
"github.com/vova616/GarageEngine/spaceCookies/server"
"github.com/vova616/GarageEngine/zumbies"
//"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() {
runtime.GOMAXPROCS(8)
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()
Start()
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.GameSceneGeneral
_ = networkOnline.GameSceneGeneral
_ = login.LoginSceneGeneral
_ = zumbies.GameSceneGeneral
/*
Running local server.
*/
go server.StartServer()
scene := 0
engine.LoadScene(login.LoginSceneGeneral)
for engine.MainLoop() {
if input.KeyPress('`') {
scene = (scene + 1) % 3
switch scene {
case 0:
engine.LoadScene(login.LoginSceneGeneral)
case 1:
engine.LoadScene(networkOnline.GameSceneGeneral)
case 2:
engine.LoadScene(zumbies.GameSceneGeneral)
}
}
}
}