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 {
|
func NewGame(id string, width, height float64) *game {
|
||||||
return &game{
|
g := &game{
|
||||||
id: id,
|
id: id,
|
||||||
register: make(chan *player),
|
register: make(chan *player),
|
||||||
unregister: make(chan *player),
|
unregister: make(chan *player),
|
||||||
@ -39,9 +39,7 @@ func NewGame(id string, width, height float64) *game {
|
|||||||
sunregister: make(chan *Spectator),
|
sunregister: make(chan *Spectator),
|
||||||
kill: make(chan bool),
|
kill: make(chan bool),
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (g *game) run() {
|
|
||||||
g.robot_id = make(chan int)
|
g.robot_id = make(chan int)
|
||||||
go func() {
|
go func() {
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
@ -49,6 +47,11 @@ func (g *game) run() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
return g
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *game) run() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-g.kill:
|
case <-g.kill:
|
||||||
|
Loading…
Reference in New Issue
Block a user