29 lines
634 B
Java
29 lines
634 B
Java
import java.awt.*;
|
|
import java.util.*;
|
|
|
|
public class Piece {
|
|
ArrayList<Integer> legalMoves;
|
|
Position pos;
|
|
Image sprite;
|
|
String color;
|
|
|
|
public Piece(int x, int y, String color, Image sprite) {
|
|
this.pos = new Position(x, y);
|
|
this.color = color;
|
|
this.sprite = sprite;
|
|
}
|
|
|
|
public void draw(Graphics g) {
|
|
g.drawImage(sprite, pos.x * 40, pos.y * 40, null);
|
|
}
|
|
|
|
public ArrayList<Position> getLegalMoves(Board board) {
|
|
System.out.println("parent method not overriden");
|
|
return null;
|
|
}
|
|
|
|
public boolean colorMatches(Piece p) {
|
|
return this.color.equals(p.color);
|
|
}
|
|
}
|