Exemple #1
0
        static void Draw()
        {
            var screen = new Text.StringBuilder(new string(' ', PlayWid * PlayHgt));

            for (int i = 0; i < leftPaddleHeight; i++)
            {
                screen[(leftPaddleY + i) * PlayWid + leftPaddleX] = '█';
            }
            for (int i = 0; i < rghtPaddleHeight; i++)
            {
                screen[(rghtPaddleY + i) * PlayWid + rghtPaddleX] = '█';
            }
            screen[ballY * PlayWid + ballX] = '█';

            string s = leftScore.ToString();

            screen.Replace(new string(' ', s.Length), s, 1, s.Length);
            string t = rghtScore.ToString();

            screen.Replace(new string(' ', t.Length), t, PlayWid - t.Length - 1, t.Length);

            Console.CursorVisible = false;
            Console.SetCursorPosition(0, 0);
            Console.Write(screen);
        }