diff --git a/game.go b/game.go index 147b185..42960cf 100644 --- a/game.go +++ b/game.go @@ -24,7 +24,7 @@ type game struct { } func NewGame(id string, width, height float64) *game { - return &game{ + g := &game{ id: id, register: make(chan *player), unregister: make(chan *player), @@ -39,9 +39,7 @@ func NewGame(id string, width, height float64) *game { sunregister: make(chan *Spectator), kill: make(chan bool), } -} -func (g *game) run() { g.robot_id = make(chan int) go func() { for i := 0; ; i++ { @@ -49,6 +47,11 @@ func (g *game) run() { } }() + return g + +} + +func (g *game) run() { for { select { case <-g.kill: