JS1K Submission

by Tgwizman

HTML

<canvas id="c">Gots to get a better browser, yo.</canvas>

CSS

* {
    margin: 0;
    padding: 0;
}

JavaScript

function n(){for(x.fillStyle="#000",x.fillRect(0,0,w,h),i=0;1e3>i;i++){var n=f[i],e=n.a,o=2/n.a,r="175,175,255",u=1;3==n.b?(u=3,r="255,175,175"):0==n.b&&(u=2,r="255,255,255"),x.fillStyle="rgba("+r+","+o+")",x.beginPath(),x.arc(n.x/e+p,n.y/e+q,u/e,0,2*P),x.closePath(),x.fill()}x.strokeStyle="#FFF",x.strokeRect(p,q/4*3,1,q/2),x.strokeRect(p/4*3,q,p/2,1),x.strokeRect(p-j,q-10,1,20),x.strokeRect(p-10,q+k,20,1),x.beginPath(),x.arc(p,q,p/9,0,2*P),x.closePath(),x.stroke()}function o(){var t=1e3;for(i=0;t>i;i++)a=f[i],t<a.x&&(a.x=-t),t<a.y&&(a.y=-t),-t>a.x&&(a.x=t),-t>a.y&&(a.y=t),.1>a.a&&(a.a=10),a.a-=.1,a.x+=j,a.y+=k;n(),setTimeout(function(){o()},50)}d=document,c=d.getElementById("c"),x=c.getContext("2d"),W=window;w=c.width=W.innerWidth,h=c.height=W.innerHeight,m=Math,P=m.PI,R=m.random,f=[],p=w/2,q=h/2;for(i=j=k=0;1e3>i;i++)f.push({b:m.floor(5*R()),x:2e3*(R()-.5),y:2e3*(R()-.5),a:10*R()});d.onkeydown=function(n){switch(n.keyCode){case 37:j+=10;break;case 38:k-=10;break;case 39:j-=10;break;case 40:k+=10}};o()