-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTile.java
More file actions
48 lines (37 loc) · 921 Bytes
/
Tile.java
File metadata and controls
48 lines (37 loc) · 921 Bytes
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
package board;
import java.awt.BorderLayout;
import java.awt.Color;
import piece.Piece;
public class Tile extends ImagePanel{
int x;
int y;
protected Piece piece = null;
Tile(){
}
Tile(int x, int y, Piece piece){
this.x = x;
this.y = y;
this.piece = piece;
if((x+y)%2 == 0)
Board.panel[x][y].setBackground(Color.white);
else
Board.panel[x][y].setBackground(Color.gray);
if(piece!=null)
setPiece(piece);
}
public boolean isEmptyTile(Tile tile) { /*board[][] Çü½ÄÀ¸·Î ÀÎÀÚ µé¾î¿È*/
if(tile.piece==null)
return true;
return false;
}
public Piece getPiece() {
return piece;
}
public void setPiece(Piece piece) {
Board.image[x][y].setImage(piece.getImage());
Board.panel[x][y].add(Board.image[x][y], BorderLayout.CENTER);
}
public int getColor() {
return piece.color;
}
}