xxxxxxxxxx
72
let bubbles = [];
function setup() {
createCanvas(600, 600);
for (let b_values = 0 ; b_values <10; b_values++){
// let x = 20 + 30*b_values; // - AUDI
// random value section
let x = random(width);
let y = random(height);
let r = random(10,40);
let xspeed = random(-10,10);
let yspeed = random(-10,10);
// And the values are insterted in the next line
bubbles[b_values] = new Bubble(x,y,r,xspeed,yspeed);
}
}
// function mousePressed(){
// let r = random(10,40);
// let xspeed = random(-10,10);
// let yspeed = random(-10,10);
// let b = new Bubble(mouseX,mouseY,r,xspeed,yspeed)
// bubbles.push(b);
// }
function draw() {
background(20);
for (let b_values = 0; b_values < bubbles.length; b_values++){
//Command Section
bubbles[b_values].move();
bubbles[b_values].bounce();
bubbles[b_values].show();
}
}
// class Bubble {
// constructor(inx,iny,inr,xspeed,yspeed) {
// this.x = inx;
// this.y = iny;
// this.r = inr;
// this.xspeed = xspeed
// this.yspeed = xspeed
// }
// move() {
// this.x = this.x + this.xspeed;
// this.y = this.y + this.yspeed;
// }
// bounce(){
// if (this.x >= width || this.x <= 0) {
// this.xspeed = this.xspeed * -1;
// }
// if (this.y >= height || this.y <= 0) {
// this.yspeed = this.yspeed * -1;
// }
// }
// show() {
// stroke(255);
// strokeWeight(4);
// noFill();
// ellipse(this.x, this.y, this.r*2);
// }
// }