-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameSquare.java
64 lines (54 loc) · 1.57 KB
/
GameSquare.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
import java.awt.Color;
import java.awt.Graphics;
public class GameSquare {
private final int length = 25; //length of a game square
private int dx; //Center block top left hand corner x-coordinate
private int dy; //Center block top left hand corner y-coordinate
private boolean iswall; //Is this GameSquare a wall
private boolean hasdot; //Does this GameSquare contain a dot
private boolean hasbigdot; //Does this GameSquare have a big dot
public GameSquare(boolean a, boolean b, boolean c, int y,int x) {
iswall=a;
hasdot=b;
hasbigdot=c;
dx=x*25;
dy=y*25;
}
/*Draws the GameSquares
* If a wall it is a blue outlined square
* If a dot it is a small white circle
* If a big dot it is a big white circle
*/
public void draw(Graphics g) {
if(iswall) {
g.setColor(Color.BLUE);
g.drawRect(dx, dy, length, length);
}else if(hasdot) {
g.setColor(Color.WHITE);
g.fillOval(dx+8, dy+8, 11, 11);
}else if(hasbigdot){
g.setColor(Color.WHITE);
g.fillOval(dx+3, dy+3, 20, 20);
}
}
//Returns true if the gamesquare is a wall
public boolean isWall() {
return iswall;
}
//Returns true if the gamesquare has a (small) dot in it
public boolean hasDot() {
return hasdot;
}
//Removes the (small) dot in a gamesquare
public void removeDot() {
hasdot=false;
}
//Returns true if the gamesquare has a big dot
public boolean hasBigDot() {
return hasbigdot;
}
//Removes the big dot from the gamesquare
public void removeBigDot() {
hasbigdot=false;
}
}