LINES:"+info.lines+"
SPEED:"+info.speed;
rotate(0);
run=setInterval("pause||down()",~~(Math.pow(1.3,12-info.speed)*30+20));
}
function over(){
document.onkeydown=null;
alert("GAME OVER");
}
function nextdia(){
next={d:tatris[~~(Math.random()*7)],s:~~(Math.random()*4)};
}
function update(t){
bak={fk:pos.fk.slice(0),y:pos.y,x:pos.x,s:pos.s};
if(t) return;
for(var i=0,a2=""; i<22; i++)
a2+=map[i].toString(2).slice(1,-1)+"
";
for(var i=0,n; i<4; i++)
if(/([^0]+)/.test(bak.fk[i].toString(2).replace(/1/g,char.t)))
a2=a2.substr(0,n=(bak.y+i+1)*15-RegExp.$_.length-4)+RegExp.$1+a2.slice(n+RegExp.$1.length);
document.getElementById("box").innerHTML=a2.replace(/1/g,char.s).replace(/0/g,char.x);
}
function is(){
for(var i=0; i<4; i++)
if((pos.fk[i]&map[pos.y+i])!=0) return pos=bak;
}
function rotate(r){
var f=dia[pos.s=(pos.s+r)%dia.length];
for(var i=0; i<4; i++)
pos.fk[i]=(f>>(12-i*4)&15)<
}
function down(){
++pos.y;
if(is()){
for(var i=0, r=0; i<4 && pos.y+i<22; i++)
if((map[pos.y+i]|=pos.fk[i])==0xfff){
map.splice(pos.y+i,1), map.unshift(0x801);
++info.lines%20==0 && info.speed++, r++;
}
clearInterval(run);
if(map[1]!=0x801) return over();
info.score+=~~(Math.pow(r,1.5)*10)+2;
start();
}
update();
}
function move(t,k){
pos.x+=k;
for(var i=0; i<4; i++)
pos.fk[i]*=t;
update(is());
}
document.onkeydown=function(e){
eval("pause||"+keycom[(e?e:event).keyCode]);
};
nextdia();
start();
script>