-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (42 loc) · 964 Bytes
/
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
/*
This is an example of application that will use the
engine package to test things out
*/
package main
import (
"os"
"os/signal"
"syscall"
"github.com/spaghettifunk/anima/engine"
"github.com/spaghettifunk/anima/engine/core"
"github.com/spaghettifunk/anima/testbed"
)
func main() {
tb, err := testbed.NewTestGame()
if err != nil {
panic(err.Error())
}
engine, err := engine.New(tb.Game)
if err != nil {
panic(err.Error())
}
if err := engine.Initialize(); err != nil {
panic(err.Error())
}
// signal channel to capture system calls
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
// start shutdown goroutine
go func() {
// capture sigterm and other system call here
<-sigCh
if err := engine.Shutdown(); err != nil {
panic(err.Error())
}
core.LogInfo("engine shutdown. Bye Bye")
}()
// run engine
if err := engine.Run(); err != nil {
panic(err.Error())
}
}