-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRain.pde
59 lines (51 loc) · 1.75 KB
/
Rain.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
/*
Class that handles rain with raindrops as aggregate objects.
This class should handle the rain and how much precipitation should be drawn on screen
The constructor sets an amount of precipitation based on an input variable, which has three,
layers of rain that differ in colour to simulate a depth of field in the rain.
*/
class Rain{
int rainPrecipitation;
float minSpeed;
float maxSpeed;
int lTermPoint;
ArrayList<Raindrop> bigRaindrop;
ArrayList<Raindrop> mediumRaindrop;
Rain(int inputPrecip, int inpLTermPoint, float inpMinSpeed, float inpMaxSpeed){
rainPrecipitation = inputPrecip;
bigRaindrop = new ArrayList<Raindrop>();
mediumRaindrop = new ArrayList<Raindrop>();
minSpeed = inpMinSpeed;
maxSpeed = inpMaxSpeed;
lTermPoint = inpLTermPoint;
for(int i = 0; i < rainPrecipitation; i++){
increaseRainPrecip();
}
}
//Raindrop
void drawRain(){
for(int i = 0; i < bigRaindrop.size(); i++){
bigRaindrop.get(i).drawRaindrop();
}
for(int i = 0; i < mediumRaindrop.size(); i++){
mediumRaindrop.get(i).drawRaindrop();
}
}
void decreaseRainPrecip(){
if(bigRaindrop.size() > 0){
bigRaindrop.remove(bigRaindrop.size() - 1);
mediumRaindrop.remove(mediumRaindrop.size() - 1);
}
}
void increaseRainPrecip(){
if(bigRaindrop.size() < 250){
bigRaindrop.add(new Raindrop((int)random(width), (int)random(height),
(float)round(random(minSpeed, maxSpeed)), 2.0, color(135,206,250), lTermPoint));
mediumRaindrop.add(new Raindrop((int)random(width), (int)random(height),
(float)round(random(minSpeed, maxSpeed)), 1.0, color(0,191,255), lTermPoint));
}
}
int getRainPrecip(){
return bigRaindrop.size();
}
}