put more of game init in NewGame
This commit is contained in:
parent
9bccf60abc
commit
325a5c0f57
9
game.go
9
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:
|
||||
|
Loading…
Reference in New Issue
Block a user