Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2009 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/69016 to your computer and use it in GitHub Desktop.
Save anonymous/69016 to your computer and use it in GitHub Desktop.
javascript:(function(d,s,h,B,X,z,c,n,i,b,x,y,m,u,f,T,W,H,V,K){function Z(n){with(n=n.style)position='absolute',left=0,top=0,width=W,height=H,zIndex=1e6;return n}W=X*s,H=h*s;with(Z(n=d.createElement('div')))background='#ffe',opacity=0.7;Z(c=d.createElement('canvas')),c.width=W,c.height=H;d.body.insertBefore(c,d.body.firstChild),d.body.insertBefore(n,c);c=c.getContext('2d'),c.fillStyle='#000';i=X;while(--i>=0)z[i]=[];function R(){return 0|Math.random()*B.length}function r(x,y){c.fillRect(x*s+1,y*s+1,s-2,s-2)}function t(x,y,b){i=4;while(i--)r(x+(b&3),y+((b>>=2)&3)),b>>=2}function D(){n=h;while(--n>0){m=X;while(--m>=0){z[m][n]&&r(m,n)}}}function C(x,y,b){i=4;do{m=x+(b&3),n=y+((b>>=2)&3),b>>=2;}while(m>=0&&m<X&&n<h&&!z[m][n]&&--i);return i}function l(){if(!(T++%2510))if(C(x,y+1,b)){if(++V>3){i=4;while(i--)z[x+(b&3)][y+((b>>=2)&3)]=1,b>>=2;b=B[R()];x=4,y=V=0;}}else{V=0,++y};K==72?C(x-1,y,b)||x--:K==76?C(x+1,y,b)||x++:K==74?T=0:0;c.clearRect(0,0,W,H);D();t(x,y,b)}K=T=y=0,x=4,b=B[R()],d.addEventListener('keydown',function(e){K=e.keyCode;K==66?(f=b>>>16,C(x,y,u=((b>>2&13107|b<<2&52428)^52428)-f+(f<<16))?0:b=u):K==87?(f=b>>>18,C(x,y,u=((b>>2&13107|b<<2&52428)^13107)-f+(f<<18))?0:b=u):0},0),d.addEventListener('keyup',function(){K=0;},0),setInterval(l,50)})(document,8,24,[0xd951,0x88885410,0x44444516,0x44448956,0x4444459a],10,[]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment