-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathState.pde
More file actions
59 lines (51 loc) · 1.13 KB
/
State.pde
File metadata and controls
59 lines (51 loc) · 1.13 KB
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
class State{
String name;
int years;
int values[]=new int[]{30,30,30,30};
int saved[]= new int[4];
color colors[]=new color[]{#FFFFFF,#FFFFFF,#FFFFFF,#FFFFFF};
int stop=0;//anni per cui deve stare fermo
final int num_stop=2;
boolean stopped=false;
int oracles=2;
public State(String name){
this.name = name;
}
void change_values(int v[]){
for(int n=0;n<4;n++){
if(v[n]<0)colors[n]=color(255,0,0);
else if(v[n]>0)colors[n]=color(0,255,0);
else colors[n]=color(255);
values[n]+=v[n];
if(values[n]<=0){
values[n]=0;
stop=num_stop;
stopped=true;
}
}
println("stato:",name,"valori:",values[0],values[1],values[2],values[3]);
}
void increaseYear(){
if(year>0){
if((stop)>0){
stop--;
if(stop==0){
values=new int[]{50,50,50,50};
stopped = false;
}
}else{
years++;
}
}
}
void restore(){
for(int n=0;n<4;n++){
values[n]=saved[n];
}
}
void saveValues(){
for(int n=0;n<4;n++){
saved[n]=values[n];
}
}
}