package game import ( "fmt" "time" ) func (gm *Game) StartGame() { go gm.startGameSub() } func (gm *Game) startGameSub() { phases := []string{ "5", "4", "3", "2", "1", "Go!", } err := gm.changeGameState(STATE_IDLE, STATE_READY_SET, phases[0]) if err != nil { fmt.Println(err) return } for i := 1; i < len(phases); i++ { time.Sleep(1500 * time.Millisecond) err = gm.changeGamePhase(STATE_READY_SET, phases[i-1], phases[i]) if err != nil { fmt.Println(err) return } } time.Sleep(3 * time.Second) err = gm.changeGameState(STATE_READY_SET, STATE_PLAY, PHASE_NONE) if err != nil { fmt.Println(err) return } } func (gm *Game) ResetGame() { err := gm.changeGameState(STATE_ANY, STATE_IDLE, PHASE_NONE) if err != nil { fmt.Println(err) return } }