forked from APCSLowell/Chemotaxis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chemotaxis.pde
90 lines (90 loc) · 1.98 KB
/
Chemotaxis.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
Snow[] bob = new Snow[140];
void setup()
{
frameRate(50);
size(600, 600);
for (int i = 0; i < bob.length; i++)
{
bob[i] = new Snow();
}
}
void draw()
{
background(#8AC7DB);
for (int i = 0; i < bob.length; i++)
{
bob[i].move();
bob[i].show();
}
stroke(#EADDCA);
strokeWeight(3);
ellipse(mouseX, mouseY, 15, 15);
line(mouseX, mouseY+15, mouseX, mouseY+25);
line(mouseX, mouseY+25, mouseX-7, mouseY+33);
line(mouseX, mouseY+25, mouseX+7, mouseY+33);
line(mouseX, mouseY+20, mouseX-7, mouseY+20);
line(mouseX, mouseY+20, mouseX+7, mouseY+20);
}
class Snow
{
int colour;
int size;
int myX;
float myY;
float speed;
Snow()
{
colour = color(((int)(Math.random()*10)+240), ((int)(Math.random()*10)+240), ((int)(Math.random()*10)+240));
size = (int)(Math.random()*15)+8;
speed = size/1.7;
myX = (int)(Math.random()*600);
myY = (int)(Math.random()*500);
}
void move()
{
myY = myY + speed;
myX = myX + (int)(Math.random()*9)-4;
if (myY > 600)
{
myY = -50;
}
if (mousePressed==true) {
if (myX < mouseX)
{
myX = myX + (int)(Math.random()*20);
}
if (myX > mouseX)
{
myX = myX - (int)(Math.random()*20)-1;
}
}
}
void show()
{
fill(colour);
stroke(colour);
strokeWeight(2);
line(myX, myY, myX, myY+25);
line(myX-10, myY+20, myX+10, myY+6);
line(myX-10, myY+6, myX+10, myY+20);
line(myX, myY+8, myX-6, myY);
line(myX, myY+8, myX+6, myY);
line(myX, myY+18, myX+6, myY+25);
line(myX, myY+18, myX-6, myY+25);
line(myX-8, myY+17, myX-6, myY+15);
fill(#edf2fb);
strokeWeight(12);
stroke(#c1d3fe);
ellipse(100, 40, 350, 150);
ellipse(200, 40, 300, 150);
ellipse(250, 40, 300, 150);
ellipse(300, 40, 300, 150);
ellipse(400, 40, 300, 150);
ellipse(450, 40, 300, 150);
ellipse(500, 40, 300, 150);
fill(#edf2fb);
rect(0, 540, 600, 600);
fill(#edf2fb);
rect(0, 530, 600, 30);
}
}