xxxxxxxxxx
33
//Vivianna Mo
//Code! Fall 2021
//Assignment 5 - Object Oriented Programming
let bouncingBalls = [];
let img;
function preload() {
img = loadImage('an-i-oop.jpg');
}
function setup() {
createCanvas(500, 500);
for (i = 0; i < 3; i++) {
let x = random(width);
let y = random(50);
let dy = 0;
let dx = random(10);
let c = color(random(0, 255), random(0, 255), random(0, 255));
bouncingBalls[i] = new Ball(x, y, dy, dx, c);
}
}
function draw() {
background(0);
for (let ball of bouncingBalls) {
ball.update();
ball.show();
}
}