let b=[];
let t=0;
let n=2000;
let r=5;
let bBool=true;
function setup() {
createCanvas(windowWidth, windowHeight,WEBGL);
angleMode(DEGREES);
fill(0)
noStroke();
birds();
}
function draw() {
if(bBool){
background(255,255,255);
fill(0,0,0)
}else{
background(0,0,0);
fill(255,255,255)
}
orbitControl()
t=frameCount/3;
moveBirds();
}
function curveP(){
beginShape()
for (let i=0;i<300;i=i+0.25){
x=i*i/5*sin(25*i);
z=i*i/5*cos(25*i);
y=i*5;
vertex(x,-y,z);
}
endShape();
}
function moveBirds(){
push()
translate(0,60,0)
sphere(r,24,24)
pop()
for (let i=0;i<n;i++){
x=b[0][i]*b[0][i]/7*sin(25*b[0][i])//+b[3][i];
z=b[0][i]*b[0][i]/7*cos(25*b[0][i])//+b[3][i];
y=b[0][i]*5+b[3][i];
if(y>-60+r){
b[0][i]=b[0][i]-0.09*b[1][i]
b[3][i]=b[3][i]*random(0.96,1.04)
}else{
b[0][i]=180
b[3][i]=int(random(-10,10))
r=r+0.5
}
push()
translate(x,-y,z);
sphere(2,3,3)
pop()
}
if (r>width/2){
bBool=!bBool
r=5
birds()
}
}
function birds(){
b[0]=[]
b[1]=[]
b[3]=[]
for(let i=0;i<n;i++){
b[3][i]=(random(-40,20))
b[1][i]=random(0.85,1.15)
b[0][i]=(random(80,180))+b[3][i];
}
}