xxxxxxxxxx
63
var restart;
function timeToExplode() {
for (var j = 0; j < myPeaces.length; j++) {
Peace.x = width / 2;
Peace.y = 550;
}
tss.stop();
var randomBoomSound = round(random(0, 9));
print(randomBoomSound);
boomSound[randomBoomSound].play();
image(bg[2], windowWidth / 2, 768 / 2);
restart = setTimeout(Clean, 30000);
}
function Clean() {
// myPeaces.hide() ;
centerY = 390;
scene = 'Welcome';
print(scene);
background(0, 0, 0);
image(bg[0], windowWidth / 2, 768 / 2);
button = createButton('Light it up!');
button.position(windowWidth / 2 - button.size().width / 2, height / 2 - height * 0.1);
button.mousePressed(start);
// for (var i = 0; i < 100; i++) {
// myPeaces.push(new Peace(i * 20, i * 20, 20 + random(74), peaces));
// }
}
class Peace {
constructor(x, y, w, img) {
this.x = width / 2;
this.y = 550;
this.xdirection = random(-1, 1);
this.ydirection = random(-1, 1);
this.peace = random(peaces);
}
burst() {
push();
translate(this.x, this.y);
image(this.peace, 0, 0, this.peaceWidth, this.peaceWidth);
pop();
this.x += this.xdirection * 2;
this.y += this.ydirection * 2;
}
checkEdges() {
if (this.x > width || this.x < 0) {
this.xdirection = -this.xdirection;
}
}
}