Пример #1
0
        public void Run()
        {
            _commands          = new Queue <Commands>();
            _commandMultiplier = 1;

            _consoleScreen.Init(_width, _height);

            Scene scene = new Scene(_width, _height);

            // Create separate thread to listen key inputs from user
            var inputsThread = new Thread(ListenKeys);

            inputsThread.Start();

            // TODO Handle closing event

            _commandsToLog = new StringBuilder();

            while (true)
            {
                if (scene.Calculate())
                {
                    lock (_sync)
                    {
                        _commands.Clear(); // Forget all previous commands that were not executed.
                        _commandsToLog.Clear();
                        _commandMultiplier = 1;
                    }
                }

                _consoleScreen.Draw(scene);

                _consoleScreen.DrawDebug("Commands queued: " + _commandsToLog);
                _consoleScreen.DrawDebug("Multiplier: " + _commandMultiplier);

                if (!HandleUserInput(scene))
                {
                    break;
                }

                Thread.Sleep(400);
            }
        }