xxxxxxxxxx
42
var bubbles = []; //empty
function setup() {
createCanvas(400, 400);
}
function mousePressed(){
bubbles.push(new bubble(mouseX,mouseY));
}
function mouseDragged(){
bubbles.push(new bubble(mouseX,mouseY));
}
function draw() {
background(220);
for(i=0;i<bubbles.length;i++){
bubbles[i].display();
bubbles[i].move();
}
}
function bubble(xx,yy){
this.x = xx;
this.y = yy;
this.display = function(){
ellipse(this.x,this.y,10,10);
}
this.move = function(){
this.x = this.x + random(-1,1);
this.y = this.y + random(-1,1);
}
}