forked from APCSLowell/Chemotaxis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chemotaxis.pde
60 lines (56 loc) · 1.01 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
Bubble[] bob;
void setup(){
size(500,500);
bob=new Bubble[50];
for(int i=0; i<bob.length; i++){
bob[i] = new Bubble();
}
}
void draw(){
background(255,255,255);
frameRate(3);
for(int i=0;i<bob.length;i++){
bob[i].show();
bob[i].move();
}
}
class Bubble{
int myX,myY,myZ;
int myColor;
Bubble(){
myX=150;
myY=300;
myZ=15;
myColor = color(237,243,255);
}
void move(){
myX=myX+(int)(Math.random()*150-70);
myY=myY-(int)(Math.random()*50);
myZ=myZ+(int)(Math.random()*4);
if(myY<=120){
myY=mouseY;
myX=mouseX;
myZ=15;
}
}
void show(){
strokeWeight(0);
if(myY>150){
fill(myColor);
}else{
fill(245,245,255);
}
ellipse(myX,myY,myZ,myZ);
strokeWeight(1);
fill(191,191,191);
rect(90,390,60,150);
rect(30,300,200,100);
rect(0,180,70,20);
rect(50,200,20,40);
fill(162,192,255);
rect(50,240,20,60);
fill(255,255,255);
textSize(25);
text("I am a sink",50,360);
}
}