public void Start() { _outputView.DrawMenu(); _inputView.PressAnyKeyToStart(); _game = new Game(_intervalMilliseconds); // Connect input for switching tracks. var backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += delegate { _inputView.OnSwitchTrackIdPressed(1, 5, (exit, trackId) => { if (exit) { _game.Stop(); } _game.SwitchTrack(trackId); }); }; backgroundWorker.RunWorkerAsync(); _game.RegisterGameTickObserver(_outputView.DrawGame); _game.Run(); // This runs, blocking, until the game is over. _outputView.DrawGameOver(_game.Score); }
public Controller() { while (true) { OutputView.DrawMenu(); GameAction action = InputView.AwaitActionMenu(); if (action == GameAction.Stop) { break; } else if (action != GameAction.Invalid) { StartLevel((int)action); } } }