private static void PrintNextFigure(Figure nextFig)
        {
            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 4; col++)
                {
                    Console.SetCursorPosition(15 + col, 3 + row);
                    Console.Write(" ");
                }
            }

            for (int row = 0; row < nextFig.Form.GetLength(0); row++)
            {
                for (int col = 0; col < nextFig.Form.GetLength(1); col++)
                {
                    Console.SetCursorPosition(15 + col, 3 + row);
                    if (nextFig.Form[row, col] != 0)
                    {
                        ColorConsole.Write("█", GetColor(nextFig.Form[row, col]));
                    }
                    else
                    {
                        ColorConsole.Write(" ");
                    }
                }
            }
        }
 public static void Information(int score, Figure nextFig)
 {
     Console.SetCursorPosition(15, 0);
     ColorConsole.Write("SCORE: " + score, ConsoleColor.Green);
     Console.SetCursorPosition(15, 1);
     ColorConsole.Write("NEXT FIGURE: ", ConsoleColor.Green);
     PrintNextFigure(nextFig);
     Console.WriteLine();
 }
Example #3
0
 public static void UpdatePosition(Figure figure, GameField field, ref bool runGame)
 {
     KeyboardControls keyboard = new KeyboardControls();
     keyboard.OnLeftPressed += HandleOnLeftPressed;
     keyboard.OnRightPressed += HandleOnRightPressed;
     keyboard.OnRotatePressed += HandleOnRotatePressed;
     keyboard.OnEscapePressed += HandleOnEscapePressed;
     keyboard.ProcessInput();
     switch (command)
     {
         case GameCommand.none:
             break;
         case GameCommand.left:
             if (figure.PositionY > 0)
             {
                 figure.MoveLeft();
             }
             break;
         case GameCommand.right:
             if (figure.PositionY + figure.Form.GetLength(1) < field.Field.GetLength(1))
             {
                 figure.MoveRight();
             }
             break;
         case GameCommand.rotate:
             if ((figure.PositionX + figure.Form.GetLength(1) - 1 < field.Field.GetLength(0))
              && (figure.PositionY + figure.Form.GetLength(0) - 1 < field.Field.GetLength(1)))
             {
                 figure.RotateR();
             }
             break;
         case GameCommand.escape:
             runGame = false;
             break;
         default:
             break;
     }
     command = GameCommand.none;
 }