xxxxxxxxxx
24
let ball=[];//creating array to hald all balls created
function setup() {
createCanvas(windowWidth,windowHeight);//making the window the canvas
background(0);//creating background once
for(let i=0;i<50;i++){
ball[i]=new Ball();//creating 50 balls/circles
}
}
function draw() {
for(let i=0;i<50;i++){
ball[i].create();//for each ball call the create function in the ball class
ball[i].center();//for each ball call the center function
}
}
function mouseClicked(){
for(let i=0;i<50;i++){
ball[i].revers();//if the mouse is clicked reverse movment from opposite direction.
}
}
//interactiveness; can click a key and move around with the mouse to play around.