xxxxxxxxxx
40
let filts = []
let balls = []
let maxBalls = 100
function setup() {
createCanvas(400, 400);
filts.push(new Filt(width/2, height/3, width/2, 0.05))
filts.push(new Filt(width/2, 2*height/3, width/2, 0.01))
for (let i=0;i<maxBalls;i++) {
balls.push(new Part())
}
}
function draw() {
background(220);
for (let f of filts) {
f.show()
}
for (let b of balls) {
b.update()
b.show()
for (let f of filts) {
b.filterInteract(f)
}
}
//let newBalls = balls
for (let i=0;i<balls.length;i++) {
let b = balls[i]
if (b.pos.y > height*1.5) {
balls.splice(i,1)
balls.push(new Part())
}
}
}