xxxxxxxxxx
var bob;
var dingdong;
function preload() {
// Load the sound file.
// We have included both an MP3 and an OGG version.
soundFormats('mp3');
dingdong = loadSound('bell.mp3');
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
let x = random()*width;
let y = random()*height;
let vx = random()*10-5;
let vy = random()*10-5;
let r = random()*10+15
bob = new Algoblob(x,y,vx,vy,r);
}
function draw() {
background(0);
let r = noise(bob.x/50,bob.y/50)*128+128;
let g = noise(-bob.x/50+1000,bob.y/50)*128+128;
let b = noise(-bob.x/50-3500,-bob.y/50)*128+128;
fill(r,g,b);
bob.deplace();
bob.rebondit();
bob.dessine();
}
function mouseClicked(){
if ( mouseX>=0 && mouseX<=width && mouseY>=0 && mouseY<=height ) {
dingdong.play();
alea =random();
if (alea < 0.2) {
bob.x = random()*width;
bob.y = random()*height;
} else if (alea < 0.4 ) {
bob.vx *= -1;
bob.vy *= -1;
} else if (alea < 0.6 ) {
bob.vx = random()*10-5;
bob.vy = random()*10-5;
} else if (alea < 0.8 ) {
bob.x = mouseX;
bob.y = mouseY;
} else {
bob.r = random()*50+15;
}
}
}