-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.pde
131 lines (120 loc) · 2.47 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
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
class Cell// extends BaseShape
{
private color[] colors = {#FFFFFF, #FF0000, #00FF00, #0000FF};
private int x;
private int y;
private int width;
private int height;
private boolean live = false;
private color brush = 0;
private int alpha = 255;
private color pen = color(255,0,0);
private int penThickness = 0;
private int deadTime = 0;
private int team = 1;
public Cell(int x, int y, int width, int height, boolean live, int team)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.live = live;
this.team = team-1;
}
public void setLive(boolean live)
{
this.live = live;
}
public boolean getLive()
{
return this.live;
}
public int getTeam()
{
return this.team;
}
public void setTeam(int team)
{
this.team = team-1;
}
protected void drawIt()
{
if(this.live)
{
switch(team)
{
case 0:
brush = colors[0];
break;
case 1:
brush = colors[1];
break;
case 2:
brush = colors[2];
break;
case 3:
brush = colors[3];
break;
default:
brush = colors[0];
}
this.deadTime = 200/2;
}
else
{
if (this.deadTime >0)
{
switch(team)
{
case 0:
brush = color(this.deadTime*2, this.deadTime*2, this.deadTime*2);
break;
case 1:
brush = color(this.deadTime*2, 0, this.deadTime/2);
break;
case 2:
brush = color(this.deadTime/5, this.deadTime*2, 0);
break;
case 3:
brush = color(0, this.deadTime/1.5, this.deadTime*2);
break;
default:
brush = color(0, this.deadTime*2, this.deadTime*2);
}
this.deadTime-=1;
}
}
brush = (brush & 0xffffff) | (alpha << 24);
pen = (pen & 0xffffff) | (alpha << 24);
fill(brush);
if (penThickness == 0)
{
noStroke();
}
else
{
strokeWeight(penThickness);
stroke(pen);
}
rect(x, y, width, height);
}
protected int getX()
{
return x;
}
protected int getY()
{
return y;
}
public boolean pointInShape(int x1, int y1, int radius)
{
if (x1 >= x && x1 <= (x + width) && y1 >= y && y1 <= (y + height))
{
return true;
}
else
{
return false;
}
}
}