-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.pde
92 lines (75 loc) · 1.66 KB
/
Cell.pde
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
/*
Maze Generator.
Written in Processing 3.
*/
public class Cell{
public Cell(int x, int y){
this.x = x;
this.y = y;
this.isInMaze = false;;
this.walls = new Wall[4];
topLeft = false;
topRight = false;
bottomLeft = false;
bottomRight = false;
}
public Cell(Cell cell2){
this.x = cell2.x;
this.y = cell2.y;
this.isInMaze = cell2.isInMaze;
this.walls = cell2.walls;
topLeft = cell2.topLeft;
topRight = cell2.topRight;
bottomLeft = cell2.bottomLeft;
bottomRight = cell2.bottomRight;
parent = cell2.parent;
this.visited= cell2.visited;
this.hasTank = cell2.hasTank;
this.target = cell2.target;
}
public void setIsInMaze(){
this.isInMaze = true;
}
int x;
int y;
boolean isInMaze;
boolean topLeft, topRight, bottomLeft, bottomRight;
boolean visited = false;
boolean hasTank = false;
PowerUp powerUp;
Cell parent = null;
int target=-1; //0 = top, 1 = bottom, 2 = left, 3 = right
Wall[] walls; // TOP, BOTTOM, LEFT, RIGHT
public float right()
{
return y * CELL_SIZE + CELL_SIZE;
}
public float left()
{
return y * CELL_SIZE;
}
public float top()
{
return x * CELL_SIZE;
}
public float bottom()
{
return x * CELL_SIZE + CELL_SIZE;
}
public Cell getParent()
{
return this.parent;
}
public void display()
{
fill(#FF0000, 25);
noStroke();
rect(left(), top(), CELL_SIZE, CELL_SIZE);
}
public void display2()
{
fill(#00FF00, 50);
noStroke();
rect(left(), top(), CELL_SIZE, CELL_SIZE);
}
}