コード例 #1
0
ファイル: View.cs プロジェクト: carlosdaniiel07/chess-game
        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");
        }
コード例 #2
0
ファイル: View.cs プロジェクト: carlosdaniiel07/chess-game
        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");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: OnChinChin/Class-Exercises
        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);
                }
            }
        }