In JPanelChessBoard in setcolor, put (x+y)%2 == 0 instead of ==1 to

correct the chessboard.
This commit is contained in:
Juliette 2025-04-17 11:30:51 +02:00
parent ad70ff95d1
commit 40bd5cb73b
2 changed files with 2 additions and 2 deletions

View File

@ -16,7 +16,7 @@ public class Main {
testBoard.getWidth();
System.out.println(testBoard.toString());
Piece testPiece = new Piece(PieceType.Knight);
Piece testPiece = new Piece();
testPiece.getX();
testPiece.getY();
testPiece.getType();

View File

@ -108,7 +108,7 @@ public class JPanelChessBoard extends JPanel {
if(isHighlight) {
g.setColor(Color.yellow);
}
if((x+y)%2==1 || isSelect || isHighlight) {
if((x+y)%2==0 || isSelect || isHighlight) {
g.fillRect(
Math.round(x*cellWidth),
Math.round(y*cellHeight),