xxxxxxxxxx
21
let boxes = []; //list to store all the box objects
function setup() {
createCanvas(560, 390);
let text = createP("Click and drag to add box");
text.position(15, 5);
}
function draw() {
background(220);
//when the mouse is pressed, add a new box object
if (mouseIsPressed) {
let b = new Box(mouseX, mouseY);
boxes.push(b);
}
//display all the box objects
for (let i = 0; i < boxes.length; i++) {
boxes[i].display();
}
}