-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.java
183 lines (161 loc) · 4.02 KB
/
Cell.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import processing.core.PApplet;
import processing.core.PImage;
public class Cell {
PApplet sketch;
private int cellX, cellY;
private boolean topWall = true;
private boolean bottomWall = true;
private boolean leftWall = true;
private boolean rightWall = true;
private boolean visited = false;
private int cellSize = 25;
private boolean isPlayer = false;
private boolean isExit = false;
private boolean isHealthKit = false;
private boolean isClock = false;
private boolean isBishop = false;
PImage clock;
PImage healthKit;
PImage player;
public Cell(PApplet sketch, int x, int y)
{
this.sketch = sketch;
this.cellX = x;
this.cellY = y;
this.isPlayer = false;
this.isExit = false;
this.isHealthKit = false;
this.visited = false;
}
public void display()
{
sketch.stroke(0);
if(isPlayer)
{
player = sketch.loadImage("images/player.png");
sketch.tint(255,255);
sketch.image(player, cellX * cellSize - 28, cellY * cellSize - 3, 80, 30);
}
else if(isExit)
{
sketch.fill(255, 0, 0);
sketch.rect(cellX * cellSize, cellY * cellSize, cellX + 5, cellY + 5);
}
else if(isHealthKit)
{
healthKit = sketch.loadImage("images/healthKit.png");
sketch.tint(255,255);
sketch.image(healthKit, cellX * cellSize - 3, cellY * cellSize - 3, 30, 30);
}
else if(isClock)
{
clock = sketch.loadImage("images/clock.png");
sketch.tint(255,255);
sketch.image(clock, cellX * cellSize, cellY * cellSize, 25, 25);
}
else{
sketch.noFill();
}
sketch.stroke(255,0,0);
if(topWall)
{
sketch.line(cellX * cellSize, cellY * cellSize, (cellX + 1) * cellSize, cellY * cellSize);
}
if(bottomWall)
{
sketch.line(cellX * cellSize, (cellY + 1) * cellSize, (cellX + 1) * cellSize, (cellY + 1) * cellSize);
}
if(leftWall)
{
sketch.line(cellX * cellSize, (cellY + 1) * cellSize, cellX * cellSize, cellY * cellSize);
}
if(rightWall)
{
sketch.line((cellX + 1) * cellSize, cellY * cellSize, (cellX + 1) * cellSize, (cellY + 1) * cellSize);
}
}
public void makePlayer()
{
this.isPlayer = true;
}
public void makeExit()
{
this.isExit = true;
this.leftWall = false;
this.rightWall = false;
this.topWall = false;
this.bottomWall = false;
}
public void removePlayer()
{
this.isPlayer = false;
}
public void makeVisited()
{
this.visited = true;
}
public void changeRightWall(boolean tf)
{
this.rightWall = tf;
}
public void changeLeftWall(boolean tf)
{
this.leftWall = tf;
}
public void changeTopWall(boolean tf)
{
this.topWall = tf;
}
public void changeBottomWall(boolean tf)
{
this.bottomWall = tf;
}
public boolean isVisited()
{
return this.visited;
}
public boolean isExit()
{
return this.isExit;
}
public boolean hasTopWall()
{
return this.topWall;
}
public boolean hasBottomWall()
{
return this.bottomWall;
}
public boolean hasRightWall()
{
return this.rightWall;
}
public boolean hasLeftWall()
{
return this.leftWall;
}
public boolean hasClock()
{
return this.isClock;
}
public boolean hasHealthKit()
{
return this.isHealthKit;
}
public void changeHealthKit(boolean tf)
{
this.isHealthKit = tf;
}
public void changeClock(boolean tf)
{
this.isClock = tf;
}
public void changeCellSize()
{
cellSize -= 5;
}
public void notVisited()
{
this.visited = false;
}
}