<! Doctype HTML>
<HTML>
<Style type = "text/CSS">
Body {Background: #000; Font: 25px/25px ;} # box {float: Left; width: 252px; Border: #999 20px Ridge; color: #9f9; text-Shadow: 2px 3px 1px #0f0 ;}
# Info {float: Left; color: # CFC; padding: 24px;} # Next {padding: 8px; width: 105px; color: #9f9; text-Shadow: 2px 3px 1px #0f0 ;}
</Style>
</Head>
<Body> <Div id = "box"> </div> <Div id = "info"> next: <Div id = "Next"> </div> <Div id = "text"> </div> <SCRIPT type = "text/JavaScript">
VaR map = eval ("[" + array (23 ). join ("0x801,") + "0 xfff]"); var tatris = [[0x6600], [0x2222, 0xf00], [0xc600, 0x2640], [0x6c00, 0x4620], [0x4460, 0x2e0, 0x6220,0x740], [0x2260, 0xe20, 0x6440,0x4700], [0x2620,0x2700, 0 x];
VaR char = {X: "\ u3000", S: "\ u25a0", T: "\ u25a1"}; var keycom = {"38": "rotate (1) "," 40 ":" down () "," 37 ":" move (0.5) "," 39 ":" move (,-1 )", "32": "0;
Pause =! Pause "}; var Dia, POs, Bak, run, next, pause = false, info = {speed: 1, lines: 0, score: 0}; function start ()
{Dia = next. d; Bak = Pos = {FK: [], Y: 0, x: 4, S: Next. s}; nextdia (); document. getelementbyid ("Next "). innerhtml = (next. d [next. S % next. d. length] | 0x10000 ). tostring (2 ). slice (-16 ). replace (/.... /g, "$ & <br/> "). replace (/1/g, Char. t ). replace (/0/G, Char. x); document. getelementbyid ("text "). innerhtml = "score:" + info. score + "<br/> lines:" + info. lines + "<br/> 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) + "<br/>"; 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) <pos. X; Update (is ());
}
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]) = 0 xfff ){
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>
</Body>
</Html>