-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (36 loc) · 1008 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
package main
import (
"fmt"
"github.com/gambler13/agor/conf"
socketio "github.com/googollee/go-socket.io"
"github.com/sirupsen/logrus"
"os"
)
var Log *logrus.Logger
const AgorConfigEnv = "AGOR_CONFIG"
const DefaultConfig = "/etc/agor/config/config.yaml"
var canvasWidth = 640.0
var canvasHeight = 400.0
func main() {
Log = logrus.New()
configFile := os.Getenv(AgorConfigEnv)
if configFile == "" {
Log.Warnf("no config file provided with %s env variable, use default config %s", AgorConfigEnv, DefaultConfig)
configFile = DefaultConfig
}
conf, err := conf.Load(configFile)
if err != nil {
panic(fmt.Errorf("could not load config file: %w", err))
}
w := InitWorld(conf)
gl := GameLoop{
tickRate: 50,
quit: nil,
World: w,
PositionCh: make(chan PositionMsg, 300),
AddPlayerCh: make(chan socketio.Conn, 20),
RemovePlayerCh: make(chan string, 0),
}
go gl.run()
startServer(gl.AddPlayerCh, gl.RemovePlayerCh, gl.PositionCh, conf.Port)
}