M=Math;R=M.random;F=M.floor;W=H=c.width=c.height=400;B=[];D=b=2;for(i=X=p=Z=S=v=Q=0;i<4;i++){B[i]={};B[i].f=0}A=0.01;V=l=10;r='fbffff0b0b93b8ff53';onkeydown=onkeyup=function(e){E=e.keyCode;v=e.type[5]?E^37?E^39?0:V:-V:0};for($ in a)a[$[0]+($[6]||$[2])]=a[$];setInterval(function(){with(a){z=150;ce(0,0,W,W);P(Q/5+z,250,z,z,0,1);P(Q/4+175,z,t=50,300,9);P(Q/2+80,300,100,100,12,1);P(Q/.8+200,350,t,t,15,1);P(0,l,400,z,6);fc(X,W-l,t,20);X+=v;Q=(W/2-X)/l;X>W-t?X=W-t:X;X<0?X=0:X;for(i=q=0;i<4;i++){O=B[i];if(O.f<1){O.p=O.f=1;O.s=0;O.i=Z+=R()*100;O.y=R()*H/3+l;O.x=R()*400}for(k=0;k<4;k++){B[k].p>0?q++:1}if(p>=b){for(j=p=0;j<4;j++){D+=.03;V+=.01;if(B[j].p==0){D+=0.9;B[j].p=1;B[j].f=0;break}}}if(O.y>W){O.p=0}else{if(O.f>0){if(O.y+l>W-l&O.x>X-l&O.x<X+t){q>1?S+=q*D:0;O.f=Z=0;p++}else{O.s>O.i?O.y+=D:O.s++}}}fillStyle='#f00';fx('x'+F(S),0,8);ba();arc(O.x+Q/3,O.y,l,0,Math.PI*2,0);ca();fill()}}},25);function P(x,y,w,h,i,$){a.fillStyle='#'+r.substr(i,3);a.fc(x,y,w,h);$==1?(P(x+w/2-5,y,l,h,3),P(x,y+h/2-5,w,l,3)):0}
M=Math;
R = M.random;
F = M.floor;
W=H=c.width=c.height=400;
B = [];// ball array
X = 0;
a = 0;
Z=0;
S = 0;
D = 2;
b = 2;
for(i=0;i<4;i++){
B[i]={};
B[i].f=0;
}
A=0.01;
v = 0;
Q = 0;
V = 8;//player speed
colors = 'fbffff0b0b93b8ff53';
onkeydown=onkeyup=function(e){E=e.keyCode;v=e.type[5]?E^37?E^39?0:V:-V:0;}
for($ in C)C[$[0]+($[6]||$[2])]=C[$]
setInterval(function(){
C.ce(0,0,W,W)
P(Q/5+150,250,150,150,0,1)
P(0,0,400,100,6)
P(Q/4+175,100,50,300,9)
P(Q/2+80,300,100,100,12,1)
P(Q/.8+200,350,50,50,15,1)
C.fx('x'+F(S),10,20);
X+=v;
Q=(W/2-X)/10; //parallax
X>W-40?X=W-40:X;X<0?X=0:X;//paddle position
C.fillStyle = '#000';
C.fillRect(X, W-10, 40, 20);
for(i=bp=0;i<4;i++){
O=B[i];
if(O.f==0){
O.a=O.f=1;
O.s = 0; // begining time
O.i = Z += R()*100; //wait time
O.y = R()*H/4;
O.x = R()*400;
O.c = 'rgb('+F(R()*255)+','+F(R()*255)+','+F(R()*255)+')';
}
for(k=0;k<4;k++){
if(B[k].a!=0){bp++;}
}
if(a>=b){
for(j=0;j<4;j++){
a=0;
D+=.03;
V+=.01;
if(B[j].a==0){
D+=0.9;
B[j].a = 1;
B[j].f=0;
break;
}
}
}
if(O.y > W){// has ball reached the ground?
O.a = 0;
}else{
if(O.f==1){
if(O.y+10 > W-10 & O.x > X-10 & O.x < X+50){ // ball has been caught
if(bp>1){S+=bp*D;}
O.f = 0;
Z = 0;
a++;
}else{
if(O.s >= O.i){ //if wait time is over, drop
O.y+=D;
}else{
O.s++;
}
}
}
}
C.fillStyle = O.c;
C.beginPath();
C.arc(O.x+Q/3, O.y, 10, 0, Math.PI*2, true);
C.closePath();
C.fill();
}
},20);
function P(x,y,w,h,i,present){
C.fillStyle = '#'+colors.substr(i,3);
C.fillRect(x, y, w, h);
present==1?(CP(x+w/2-5, y, 10, h, 3),CP(x, y+h/2-5, w, 10, 3)):0;
}