pawn moves check
This commit is contained in:
24
Knight.java
Normal file
24
Knight.java
Normal file
@@ -0,0 +1,24 @@
|
||||
import java.util.*;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class Knight extends Piece {
|
||||
static int[] xDir = {-1, -2, -2, -1, 1, 2, 2, 1};
|
||||
static int[] yDir = {-2, -1, 1, 2, 2, 1, -1, -2};
|
||||
|
||||
public Knight(int x, int y, String color) {
|
||||
super(x, y, color, new ImageIcon("sprites/" + color + "/knight.png").getImage());
|
||||
}
|
||||
|
||||
public ArrayList<Position> getLegalMoves(Board board) {
|
||||
ArrayList<Position> positions = new ArrayList<Position>();
|
||||
|
||||
for (int i : xDir) {
|
||||
for (int j : yDir) {
|
||||
Position test = new Position(pos.x + i, pos.y + j);
|
||||
if (!Board.inBounds(test)) continue;
|
||||
}
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user