xxxxxxxxxx
36
let balls = []
let formation
const num_entities = 5
function setup() {
createCanvas(600, 600);
for (let i = 0; i < num_entities; i++) {
balls.push(new Entity(0,0))
}
formation = new Formation(num_entities)
}
function draw() {
background(12);
balls.forEach((ball,i) => {
ball.shouldUpdate = true
if(mouseIsPressed) {
let spot = createVector(
formation.spots[i].x,
formation.spots[i].y
)
ball.gotoAssignedSpot(spot)
ball.shouldUpdate = false
}
ball.move()
ball.show()
})
formation.update()
}