-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlight.pde
55 lines (52 loc) · 888 Bytes
/
light.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
class Light{
String col;
int x,y;
Light(int x, int y){
this.x = x;
this.y = y;
this.col = "red";
}
void drawLight(){
fill(200);
noStroke();
rect(this.x, this.y, 30, 90);
if(this.col.equals("red")){
fill(250, 0, 0);
}
else{
fill(100);
}
ellipse(this.x+15, this.y+15, 20, 20);
if(this.col.equals("yellow")){
fill(250, 250, 0);
}
else{
fill(100);
}
ellipse(this.x+15, this.y+45, 20, 20);
if(this.col.equals("green")){
fill(0, 250, 0);
}
else{
fill(100);
}
ellipse(this.x+15, this.y+75, 20, 20);
}
void toggleLight(String col){
this.col = col;
}
void toggleLight(){
if(this.col.equals("red")){
this.col = "green";
}
else if(this.col.equals("yellow")){
this.col = "red";
}
else{
this.col = "yellow";
}
}
String getState(){
return this.col;
}
}