Beispiel #1
0
        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);
        }