Exemplo n.º 1
0
        private void GameLoop()
        {
            var stopwatch          = new Stopwatch();
            var millisecondsPassed = 0L;

            stopwatch.Start();
            while (Alive)
            {
                if (stopwatch.ElapsedMilliseconds <= 100)
                {
                    continue;
                }
                CurrentBoard.ShallowClear();
                _inputHandler.HandlePlayerMovement(KeyboardHandler.GetDirection(), true);
                if (millisecondsPassed > 1000)
                {
                    CurrentBoard.ShallowClear();
                    _inputHandler.HandlePlayerMovement(KeyCommand.Down);
                    millisecondsPassed = 0L;
                }

                if (HasChanged)
                {
                    Show();
                }
                HasChanged          = false;
                millisecondsPassed += stopwatch.ElapsedMilliseconds;
                stopwatch.Restart();
            }
        }