-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticleTag_02.pde.txt
59 lines (47 loc) · 1.25 KB
/
ParticleTag_02.pde.txt
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
//declare global variables
Bubble[] bubbles;
Bubble singleBubble;
int numBubbles = 100;//set the number of bubbles to make at 100
void setup() {
size(500, 500);
bubbles = new Bubble[numBubbles];//instantiate the custom bubbles object that will hold all the bubbles
for(int i = 0; i < numBubbles; i++) {
bubbles[i] = new Bubble(250, 100);//create the bubbles and add them into the arrau
}
singleBubble = new Bubble(250, 100);//create one bubble
}
void draw() {
background(100);
//move and display the one bubble
//it will be colored red
singleBubble.move();
singleBubble.display(color(255,0,0));
//create, move and display lots of bubbles colored white
for(int i = 0; i < numBubbles; i++) {
bubbles[i].move();
bubbles[i].display(color(255,255,255));
}
}
class Bubble {
public float x,y;
float xOff,yOff;
Bubble(int x, int y) {
x = 0;
y = 0;
xOff = random(0, 1000);
yOff = random(0, 1000);
}
void move() {
xOff += 0.01;
yOff += 0.01;
x = noise(xOff) * width;
y = noise(yOff) * height;
}
void draw(){
move();
}
void display(color c) {
fill(c);
circle(x, y, 5);
}
}