-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rain.pde
65 lines (55 loc) · 1.2 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
60
61
62
63
64
65
/*
Rain by Anastasis Chasandras
https://www.openprocessing.org/sketch/9299
*/
public class Rain {
PVector position,pposition,speed;
float col;
public Rain() {
position = new PVector(random(0,width),0);
pposition = position;
speed = new PVector(0,0);
col = random(30,100);
}
void draw() {
stroke(255,col);
strokeWeight(2);
line(position.x,position.y,pposition.x,pposition.y);
//ellipse(position.x,position.y,5,5);
}
void calculate() {
pposition = new PVector(position.x,position.y);
gravity();
}
void gravity() {
speed.y += .2;
speed.x += .01;
position.add(speed);
}
}
public class Splash {
PVector position,speed;
public Splash(float x,float y) {
float angle = random(PI,TWO_PI);
float distance = random(1,5);
float xx = cos(angle)*distance;
float yy = sin(angle)*distance;
position = new PVector(x,y);
speed = new PVector(xx,yy);
}
public void draw() {
strokeWeight(1);
stroke(100,50);
fill(255);
ellipse(position.x,position.y,2,2);
}
void calculate() {
gravity();
speed.x*=0.98;
speed.y*=0.98;
position.add(speed);
}
void gravity() {
speed.y+=.2;
}
}