-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
50 lines (43 loc) · 1.09 KB
/
sketch.js
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
var bubbles = []; // array of Jitter objects
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
// Create objects
for (var i=0; i<100; i++) {
bubbles.push(new Bubble());
}
}
function draw() {
background(50, 89, 100);
for (var i=0; i<bubbles.length; i++) {
bubbles[i].move();
bubbles[i].display();
}
}
// Bubble class
function Bubble() {
this.x = random(width);
this.y = random(height);
this.speed = 1;
this.sorte = random(1, 100);
if(this.sorte > 0 && this.sorte < 30){
this.diameter = random(2, 5);
}else if(this.sorte > 30 && this.sorte < 90){
this.diameter = random(10, 15);
}else{
this.diameter = random(10, 60);
}
this.move = function() {
this.x += random(-this.speed, this.speed);
this.y += random(-this.speed, this.speed);
};
this.display = function() {
fill(255, 100);
ellipse(this.x, this.y, this.diameter, this.diameter);
};
}
function mouseMoved(){
//bugs.pop(); //esse retira os ultimos adicionados.
bubbles.splice(0, 1); //esse retira o mais antigo.
bubbles.push(new Bubble());
}