-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGamePiece.java
70 lines (58 loc) · 1.54 KB
/
GamePiece.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package chess;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.JButton;
public abstract class GamePiece{
private Point2D.Double location;
private ArrayList<BufferedImage> sprite;
private boolean selectedPiece;
protected boolean isTeamLight;
public GamePiece(double x, double y, boolean _isTeamLight){
location = new Point2D.Double(x, y);
isTeamLight = _isTeamLight;
}
/**
* Method checks if the Tile selected for movement is a legal chess move
* @param tile
* @return boolean true/false
*/
public abstract boolean validMove(Tile tile);
/**
* Method 'selects' piece and adds a border around it.
*/
public void selectPiece(){
// addBorder(sprite);
// selectedPiece = true;
}
/**
* Method is supposed to add a border around the piece, so that the use knows it's selected.
* @param oldImage
* @return
*/
public BufferedImage addBorder(BufferedImage oldImage){
return null;
}
public void loadSprite(String fileName){
sprite = new ArrayList<BufferedImage>();
BufferedImage img = null;
try {
img = ImageIO.read(new File(fileName));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sprite.add(img);
}
/**
* returns pieces XY location
* @return
*/
public Double getLocation(){
return location;
}
}