(function(){c.width=640,c.height=480,document.onkeydown=function(a){var b=a.keyCode;b==65&&(e=!0),b==90&&(f=!0),b==59&&(g=!0),b==190&&(h=!0)},document.onkeyup=function(a){var b=a.keyCode;b==65&&(e=!1),b==90&&(f=!1),b==59&&(g=!1),b==190&&(h=!1)};var b=200,d=300,e=!1,f=!1,g=!1,h=!1,i=0,j=0,k=320,l=240,m=.52,n=1,o=1,p,q=function(){e&&(b-=8),f&&(b+=8),g&&(d-=8),h&&(d+=8),b<0&&(b=0),b>340&&(b=340),d<0&&(d=0),d>340&&(d=340);if(k<25){p=l>b||l+240<b,p&&(m+=(l-120-b)/9600);if(p||k<6)n*=-1;k<6&&j++}if(k>615){p=l>d||l+240<d,p&&(m+=(l+120-d)/9600);if(p||k>634)n*=-1;k>634&&i++}if(l>480||l<0)o*=-1;ballAndlge=m%1,k+=Math.acos(m)*7*n,l+=Math.asin(m)*7*o,a.clearRect(0,0,640,480),a.beginPath(),console.log(m),a.arc(k,l,10,0,6.3,!0),a.closePath(),a.fill(),a.fillRect(0,b,20,140),a.fillRect(620,d,20,140),a.fillText(i,30,20),a.fillText(j,610,20),setTimeout(q,20)};q()})()
(function(){
c.width = 640;
c.height = 480;
document.onkeydown = function(evt){
var c = evt.keyCode;
if(c==65)pl1t = true;
if(c==90)pl1b = true;
if(c==59)pl2t = true;
if(c==190)pl2b = true;
}
document.onkeyup = function(evt){
var c = evt.keyCode;
if(c==65)pl1t = false;
if(c==90)pl1b = false;
if(c==59)pl2t = false;
if(c==190)pl2b = false;
}
var pl1 = 200,
pl2 = 300,
pl1t = false,
pl1b = false,
pl2t = false,
pl2b = false,
pl1s = 0,
pl2s = 0,
ballX = 320,
ballY = 240,
ballAngle = 0.52,
x=1,
y=1,
cond,
main = function(){
if(pl1t)pl1-=8
if(pl1b)pl1+=8
if(pl2t)pl2-=8
if(pl2b)pl2+=8
if(pl1<0)pl1=0
if(pl1>340)pl1=340
if(pl2<0)pl2=0
if(pl2>340)pl2=340
if(ballX < 25){
cond = ballY>pl1 || (ballY+240)<pl1;
if(cond){
ballAngle += (ballY - 120 - pl1)/9600;
}
if(cond || ballX<6)x *= -1;
if(ballX<6){
pl2s++;
}
}
if(ballX > 615){
cond = ballY>pl2 || (ballY+240)<pl2;
if(cond){
ballAngle += (ballY + 120 - pl2)/9600;
}
if(cond || ballX>634)x *= -1;
if(ballX>634){
pl1s++;
}
}
if(ballY > 480 || ballY < 0){
y *= -1;
}
ballAndlge = ballAngle%1;
ballX += Math.acos(ballAngle)*7*x;
ballY += Math.asin(ballAngle)*7*y;
a.clearRect(0,0,640,480);
a.beginPath();
console.log(ballAngle)
a.arc(ballX, ballY, 10, 0, 6.3, true);
a.closePath();
a.fill();
a.fillRect(0,pl1,20,140);
a.fillRect(620,pl2,20,140);
a.fillText(pl1s,30,20)
a.fillText(pl2s,610,20)
setTimeout(main,20);
}
main()
})();