Roxen.git / server / protocols / tetris.pike

version» Context lines:

Roxen.git/server/protocols/tetris.pike:1:   #!/usr/local/bin/pike   //#pike 7.2 - // $Id: tetris.pike,v 1.6 2006/10/24 15:36:49 jonasw Exp $ + // $Id$   import Process;import Protocols.TELNET;mixed a,h,Q,e=([]),q=Q=([]),c,s,I,_,j,K,   w,x=252,m,f=map((array)"H45BBI65@CJ@BMED45@GM@LBFP@NBHS@BCDA5@LBB5BNCK5BMEL5@B"   "EC5@MEN5MNFO6@BFE45MFQ65MHR4B@HF5MLHG5MYD",`-,65),n=25,io,tm;int u(){foreach(   sort(indices(Q)),_)_>11&&_<264&&Q[_]-e[_]&&io->write((_-++I||_%12<1?sprintf(   "\e[%d;%dH",(I=_)/12,_%12*2+28):"")+(Q[_]-K?(K=Q[_])?"\e[7;3"+(K-w)+"m":"\e[0m"   :"")+" ");Q=([263:7]);e=q+Q;e[263]=0;}int g(int b){for(_=4;_--;Q[m=_?x+f[n+_]:   x]=q[m]=b&&f[n+4]);}int G(int b){for(_=4;_--;)if(q[_?b+f[n+_]:b])return 1;}int   z(int p);void tick(){h-=h/3e3;call_out(tick,h);g(0);if(G(x+12)){g(++s);for(m=j=   0;++j<252;)if(q[j]?++m>9&&j%12==10:(m=0)){for(;j%12;q[j]=Q[j--]=0);for(;--j;q[j   +12]=Q[j+12]=q[j]);}n=random(7)*5;G(x=17)&&z(1);}else x+=12;g(7);u();}void key(