diff --git a/src/schack/Board.java b/src/schack/Board.java index ab98d02..b71ba19 100644 --- a/src/schack/Board.java +++ b/src/schack/Board.java @@ -14,7 +14,7 @@ import javax.swing.JPanel; public class Board extends JPanel { - public static final int SCALE = 100; + public static final int SIZE_OF_TILE = 100; ArrayList pieces = new ArrayList<>(); public Board() throws IOException { @@ -50,9 +50,9 @@ public class Board extends JPanel { pieces.forEach(p -> p.draw(g2)); Piece p = pieces.get(1); - LinkedHashSet legal = p.legalMoves(pieces); + LinkedHashSet legal = p.validMoves(pieces); g2.setColor(Color.yellow); - legal.forEach(point -> g2.fillOval(point.x * SCALE, point.y * SCALE, SCALE, SCALE)); + legal.forEach(point -> g2.fillOval(point.x * SIZE_OF_TILE, point.y * SIZE_OF_TILE, SIZE_OF_TILE, SIZE_OF_TILE)); System.out.println(legal.size()); } @@ -64,13 +64,13 @@ public class Board extends JPanel { for (int i = 0; i < 8; i += 2) { for (int j = 0; j < 8; j += 2) { - g2.fillRect(i * SCALE, j * SCALE, 1 * SCALE, 1 * SCALE); + g2.fillRect(i * SIZE_OF_TILE, j * SIZE_OF_TILE, 1 * SIZE_OF_TILE, 1 * SIZE_OF_TILE); } } for (int i = 1; i < 8; i += 2) { for (int j = 1; j < 8; j += 2) { - g2.fillRect(i * SCALE, j * SCALE, 1 * SCALE, 1 * SCALE); + g2.fillRect(i * SIZE_OF_TILE, j * SIZE_OF_TILE, 1 * SIZE_OF_TILE, 1 * SIZE_OF_TILE); } } diff --git a/src/schack/King.java b/src/schack/King.java index c4372f9..4f4fd07 100644 --- a/src/schack/King.java +++ b/src/schack/King.java @@ -7,7 +7,6 @@ import java.io.IOException; import java.nio.file.Paths; import java.util.ArrayList; import java.util.LinkedHashSet; -import java.util.LinkedList; import javax.imageio.ImageIO; public final class King extends Piece { @@ -31,7 +30,7 @@ public final class King extends Piece { } @Override - public LinkedHashSet legalMoves(ArrayList pieces) { + public LinkedHashSet validMoves(ArrayList pieces) { LinkedHashSet unmovable = new LinkedHashSet<>(); LinkedHashSet perhapsMovable = new LinkedHashSet<>(); for (Piece piece : pieces) { diff --git a/src/schack/Piece.java b/src/schack/Piece.java index 0307136..33f9f1a 100644 --- a/src/schack/Piece.java +++ b/src/schack/Piece.java @@ -20,11 +20,11 @@ public abstract class Piece extends Component { this.position = startingPosition; } - public abstract LinkedHashSet legalMoves(ArrayList pieces); + public abstract LinkedHashSet validMoves(ArrayList pieces); public void draw(Graphics2D g2) { - g2.drawImage(icon, position.x * Board.SCALE, position.y * Board.SCALE, (ImageObserver) this); + g2.drawImage(icon, position.x * Board.SIZE_OF_TILE, position.y * Board.SIZE_OF_TILE, (ImageObserver) this); // g2.drawImage(icon, 4 * Board.SCALE, 6* Board.SCALE, (ImageObserver) this); } diff --git a/src/schack/Schack.java b/src/schack/Schack.java index c51dc9f..6c1f9c9 100644 --- a/src/schack/Schack.java +++ b/src/schack/Schack.java @@ -17,8 +17,6 @@ import javax.swing.JOptionPane; */ public class Schack extends JFrame { - public Dimension size = new Dimension(800, 800); - public Schack() throws IOException { setTitle("Schack"); setAlwaysOnTop(true);