diff --git a/src/chess/Bishop.java b/src/chess/Bishop.java index a17e888..634f564 100644 --- a/src/chess/Bishop.java +++ b/src/chess/Bishop.java @@ -7,8 +7,8 @@ import static ui.Display.loadImage; public class Bishop extends ChessPiece { - private Image whiteBishop = loadImage("./resources/chess_piece_2_black_bishop.png"); - private Image blackBishop = loadImage("./resources/chess_piece_2_white_bishop.png"); + private Image whiteBishop = loadImage("./resources/chess_piece_2_white_bishop.png"); + private Image blackBishop = loadImage("./resources/chess_piece_2_black_bishop.png"); public Bishop(Board b, boolean isWhite, int x, int y) { super(b,isWhite,x,y); diff --git a/src/chess/King.java b/src/chess/King.java index bc3f615..7fe8025 100644 --- a/src/chess/King.java +++ b/src/chess/King.java @@ -7,8 +7,8 @@ import static ui.Display.loadImage; public class King extends ChessPiece { - private final Image whiteKing = loadImage("./resources/chess_piece_2_black_king.png"); - private final Image blackKing = loadImage("./resources/chess_piece_2_white_king.png"); + private final Image whiteKing = loadImage("./resources/chess_piece_2_white_king.png"); + private final Image blackKing = loadImage("./resources/chess_piece_2_black_king.png"); public King(Board b, boolean isWhite, int x, int y) { super(b,isWhite,x,y); diff --git a/src/chess/Knight.java b/src/chess/Knight.java index faa0ebd..9329d84 100644 --- a/src/chess/Knight.java +++ b/src/chess/Knight.java @@ -7,8 +7,8 @@ import static ui.Display.loadImage; public class Knight extends ChessPiece { - private Image whiteKnight = loadImage("./resources/chess_piece_2_black_knight.png"); - private Image blackKnight = loadImage("./resources/chess_piece_2_white_knight.png"); + private final Image whiteKnight = loadImage("./resources/chess_piece_2_white_knight.png"); + private final Image blackKnight = loadImage("./resources/chess_piece_2_black_knight.png"); public Knight(Board b, boolean isWhite, int x, int y) { super(b,isWhite,x,y); diff --git a/src/chess/Pawn.java b/src/chess/Pawn.java index 2127631..808b37f 100644 --- a/src/chess/Pawn.java +++ b/src/chess/Pawn.java @@ -7,8 +7,8 @@ import java.util.ArrayList; public class Pawn extends ChessPiece { - private Image white = Display.loadImage("./resources/chess_piece_2_black_pawn.png"); - private Image black = Display.loadImage("./resources/chess_piece_2_white_pawn.png"); + private Image white = Display.loadImage("./resources/chess_piece_2_white_pawn.png"); + private Image black = Display.loadImage("./resources/chess_piece_2_black_pawn.png"); public Pawn(Board b, boolean isWhite, int x, int y) { super(b,isWhite,x,y); diff --git a/src/chess/Queen.java b/src/chess/Queen.java index 2b7755b..9739f33 100644 --- a/src/chess/Queen.java +++ b/src/chess/Queen.java @@ -7,8 +7,8 @@ import static ui.Display.loadImage; public class Queen extends ChessPiece { - private Image whiteQueen = loadImage("./resources/chess_piece_2_black_queen.png"); - private Image blackQueen = loadImage("./resources/chess_piece_2_white_queen.png"); + private Image whiteQueen = loadImage("./resources/chess_piece_2_white_queen.png"); + private Image blackQueen = loadImage("./resources/chess_piece_2_black_queen.png"); public Queen(Board b, boolean isWhite, int x, int y) { super(b,isWhite,x,y); diff --git a/src/chess/Rook.java b/src/chess/Rook.java index 4664fda..2847c83 100644 --- a/src/chess/Rook.java +++ b/src/chess/Rook.java @@ -7,8 +7,8 @@ import static ui.Display.loadImage; public class Rook extends ChessPiece { - private Image whiteRook = loadImage("./resources/chess_piece_2_black_rook.png"); - private Image blackRook = loadImage("./resources/chess_piece_2_white_rook.png"); + private Image whiteRook = loadImage("./resources/chess_piece_2_white_rook.png"); + private Image blackRook = loadImage("./resources/chess_piece_2_black_rook.png"); public Rook(Board b, boolean isWhite, int x, int y) { super(b,isWhite,x,y); diff --git a/src/ui/Display.java b/src/ui/Display.java index ae9e9fc..d990269 100644 --- a/src/ui/Display.java +++ b/src/ui/Display.java @@ -37,8 +37,9 @@ public class Display extends JFrame implements MouseListener { super.paint(g); for (int i = 0; i < b.size(); i++){ for (int j = 0; j < b.size(); j++){ - if (b.get(i,j) != null) - g.drawImage(b.get(i,j).getImage(), xOffset + (i) * width, yOffset + (j) * height, null); + var p = b.get(i,j); + if (p != null) + g.drawImage(p.getImage(), xOffset + (i) * width, yOffset + (j) * height, null); } } if (movingPointX != -1 && movingPointY != -1) {