Exemple #1
0
        public static void PrintChessBoard(ChessBoard chessBoard, ChessPosition origin)
        {
            Console.Clear();

            for (int l = 0; l < ChessBoard.Lines; l++)
            {
                PrintChessBoardVerticalLabel(l);

                for (int c = 0; c < ChessBoard.Columns; c++)
                {
                    var currentPosition = new Position(l, c);
                    bool[,] possibleMovements = chessBoard.GetPiece(origin.ToPosition()).PossibleMovements();

                    if (possibleMovements[l, c])
                    {
                        PrintChessBoardPiece(chessBoard.GetPiece(currentPosition), true);
                    }
                    else
                    {
                        PrintChessBoardPiece(chessBoard.GetPiece(currentPosition));
                    }
                }
                Console.WriteLine();
            }

            PrintChessBoardHorizontalLabel();

            Console.Write("\n\n");
        }
Exemple #2
0
        private static void PrintChessBoardOnEndOfMatch(ChessBoard chessBoard)
        {
            for (int l = 0; l < ChessBoard.Lines; l++)
            {
                PrintChessBoardVerticalLabel(l);

                for (int c = 0; c < ChessBoard.Columns; c++)
                {
                    PrintChessBoardPiece(chessBoard.GetPiece(new Position(l, c)), false);
                }

                Console.WriteLine();
            }

            PrintChessBoardHorizontalLabel();

            Console.Write("\n\n");
        }
        void DrawGamePieces()
        {
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    var piece = board.GetPiece(y, x);
                    if (piece == null)
                    {
                        continue;
                    }

                    Rectangle src = Assets.chessPieceSrcRects[piece.GetSide()][piece.GetPieceType()];

                    float xPos = x * board.tileSize + board.pos.X;
                    float yPos = y * board.tileSize + board.pos.Y;
                    var   dst  = new Rectangle(xPos, yPos, board.tileSize, board.tileSize);

                    Raylib.DrawTexturePro(Assets.chessPieceTexture, src, dst, Vector2.Zero, 0, Color.WHITE);
                }
            }
        }