allow the control interface to specify game type

This commit is contained in:
Fraser Graham
2014-01-15 22:16:06 -08:00
parent 9583de2ffa
commit 90b7731865
4 changed files with 20 additions and 11 deletions
+7 -2
View File
@@ -75,7 +75,7 @@ type GameMode interface {
gameOver(gg *game) (bool, *GameOver)
}
func NewGame(id string, width, height float32, obstacles, tick, maxPoints int) *game {
func NewGame(id string, width, height float32, obstacles, tick, maxPoints int, mode string) *game {
g := &game{
id: id,
register: make(chan *player),
@@ -98,7 +98,12 @@ func NewGame(id string, width, height float32, obstacles, tick, maxPoints int) *
tick_duration: tick,
players_remaining: 2,
winners: WinnerMap{m: make(map[string]int)},
mode: &melee{respawn: make(map[*Robot]float64)},
}
if mode == "melee" {
g.mode = &melee{respawn: make(map[*Robot]float64)}
} else {
g.mode = &deathmatch{}
}
g.mode.setup(g)