xxxxxxxxxx
59
let notes = []
function setup() {
createCanvas(800, 800, WEBGL);
let x = random(110, width - 110);
let y = random(110, height - 110);
let d = 50;
notes[0] = new Note(x, y, d);
}
class Note {
constructor(_x, _y, _d){
this.x = _x;
this.y = _y;
this.d = _d;
}
display() {
noStroke();
fill(255);
ellipse(this.x, this.y, this.d);
}
}
function draw() {
print(notes.length);
background(245,170,190);
let z = frameCount%300;
translate(-width/2, -height/2, z);
fill(127, 100);
stroke(0);
push();
translate(0, 0, -z);
rect(width*0.2, height*0.2, width*0.6, height*0.6);
pop();
if (frameCount%300 == 0) {
let x = random(110, width - 110);
let y = random(110, height - 110);
let d = 50;
// notes[++inc] = new Note(x, y, d);
notes.push(new Note(x, y, d));
print(notes.length);
if(notes.length > 0) { notes.splice(0, 1); }
}
for (i = 0; i < notes.length; i++){
notes[i].display();
}
}