A=window;D=Math;E=D.floor;F=D.sin;G=D.cos;H=D.abs;I=document;C=I.getElementById("c");C.height=P=A.innerHeight;C.width=Q=A.innerWidth;I.onmousemove=function(e){q=e.pageX-Q/2};C=C.getContext("2d");C.B=C.lineTo;d=33;c=[];for(i=8;i--;)c[i]=[E((i+1)/2%2),E(i/4),E(i/2%2)];function R(p,x,r){y=(x+1)%3;z=(x+2)%3;n=[];n[x]=p[x]*G(r)-p[z]*F(r);n[y]=p[y];n[z]=p[z]*G(r)+p[x]*F(r);return n}q=a=g=o=.2;t=[[0,0,0,1,1],[0,0,-15,5,1],[0,0,15,5,1],[-12,-1,-16,25,d]];setInterval(function(){C.clearRect(0,0,Q,P);a+=.01;for(h in t){u=[];v=t[h];if(h<1){J=v[0]+=g;K=v[2]+=o;if(H(J)>12)g=-g;if(H(K)>16)v[0]=v[2]=0}else if(h<3){v[0]=X=D.max(D.min(q/20*(h*2-3)-2,8),-12);if(K+1>v[2]&&K<v[2]+1&&J+1>X&&J<X+5)o=-o}for(i in c){Y=c[i];L=[v[0]+v[3]*Y[0],v[1]+1*Y[1],v[2]+v[4]*Y[2]];L=R(L,0,a);L=R(L,2,-a);L=R(L,1,a);u[i]=[L[0]/(L[2]-d)*P+Q/2,L[1]/(L[2]-d)*P+P/2]}C.beginPath();for(i=4;i--;){j=u[i];k=u[(i+1)*(i<3)];l=u[i+5-4*(i>2)];m=u[i+4];C.moveTo(j[0],j[1]);C.B(k[0],k[1]);C.B(l[0],l[1]);C.B(m[0],m[1]);C.strokeStyle='#A13'}C.stroke()}},d)//PINGPONG
// 3D Heyscore Pong By Ola Persson, ola@kongotec.com
// Most weird solutions below are due to minification
// Am i missing out on some obvious minification / improvements? Mail me!
// Shout Outs to HBI, ELLEN, ISAK, FREKAR
// For more CraZy Javascript games visit www.heyscore.com
A=window;
D=Math;
E=D.floor;
F=D.sin;
G=D.cos;
H=D.abs;
I=document;
C=I.getElementById("c");
C.height=P=A.innerHeight;
C.width=Q=A.innerWidth;
I.onmousemove=function(e){q=e.pageX-Q/2};
C=C.getContext("2d");
C.B=C.lineTo;
d=33; // mystery value 33
c=[];
for(i=8;i--;)c[i]=[E((i+1)/2%2),E(i/4),E(i/2%2)]; // generates the xyz cordinates for the cube corners
function R(p,x,r){ // rotation, used for all three axis. Takes p=point=[x,y,z] x=axis=(int) r=rotation in radians=(float)
y=(x+1)%3;
z=(x+2)%3;
n=[];
n[x]=p[x]*G(r)-p[z]*F(r);
n[y]=p[y];
n[z]=p[z]*G(r)+p[x]*F(r);
return n
}
q=a=g=o=.2;
t=[[0,0,0,1,1],[0,0,-15,5,1],[0,0,15,5,1],[-12,-1,-16,25,d]]; // game geometry cordinates
setInterval(function(){
C.clearRect(0,0,Q,P);
a+=.01; // rotation on all three axis
for(h in t){ // loop through all geometry
u=[];
v=t[h];
if(h<1){ // move ball wall collision
J=v[0]+=g;
K=v[2]+=o;
if(H(J)>12)g=-g;
if(H(K)>16)v[0]=v[2]=0;
}else if(h<3){ // move both paddles and collide with ball
v[0]=X=D.max(D.min(q/20*(h*2-3)-2,8),-12);
if(K+1>v[2]&&K<v[2]+1&&J+1>X&&J<X+5)o=-o;
}
for(i in c){ // rotate and calculate projected cube screen points
Y=c[i];
L=[v[0]+v[3]*Y[0],v[1]+1*Y[1],v[2]+v[4]*Y[2]];
L=R(L,0,a);
L=R(L,2,-a);
L=R(L,1,a);
u[i]=[L[0]/(L[2]-d)*P+Q/2,L[1]/(L[2]-d)*P+P/2];
}
C.beginPath(); // draw cube
for(i=4;i--;){
j=u[i];
k=u[(i+1)*(i<3)];
l=u[i+5-4*(i>2)];
m=u[i+4];
C.moveTo(j[0],j[1]);
C.B(k[0],k[1]);
C.B(l[0],l[1]);
C.B(m[0],m[1]);
C.strokeStyle='#A13';
}
C.stroke();
}
},d)//PINGPONG