Body
{
}
MB
{
Background-color: firebrick;
Cursor: Default;
HEIGHT: 22PX;
Width: 22px
}
.Sb
{
Background-color: slategray;
Cursor: Default;
HEIGHT: 22PX;
Width: 22px
}
.Bk
{
Background-color: white;
Cursor: Default;
HEIGHT: 22PX;
Width: 22px
}
.Gt
{
Border-bottom: DeepskyBlue Thin Solid;
Border-left: DeepskyBlue Thin Solid;
Border-Right: DeepskyBlue Thin Solid;
Border-top: DeepskyBlue Thin Solid;
Cursor: Default
}
->
style>
Var bx = new array (4);
Var by = new array (4);
VAR PX = New Array (4);
Var py = new array (4);
Var Mtimer
Var firstview
Function begingame ()
{
Gamestate = 0;
SPEED = 1;
Outtime = 1100-speted * 100;
SCIE = 0;
IF (GameState! = 0) return;
FigStview = true;
For (j = 0; j <16; j )
For (i = 0; i <10; i )
SetClass (i, j, "bk");
Randbar ();
Gamestate = 1;
Play.disabled = true;
WINDOW.CLARINTERVAL (Mtimer);
Mtimer = Window.setInterval ("MoveBar ()", Outtime;
}
Function KeyControl ()
{
IF (GameState! = 1) Return;
Switch (Event.Keycode) {
Case 37: {// Left
For (i = 0; i <4; i ) IF (BX [i] == 0) Return;
For (i = 0; i <4; i ) IF (getClass (BX [i] -1, by [i]) == "sb") Return;
For (i = 0; i <4; i ) setClass (BX [i], by [i], "bk");
For (i = 0; i <4; i ) bx [i] = bx [i] -1;
For (i = 0; i <4; i ) setClass (BX [i], by [i], "mb");
Break;
Case 38: {// UP
Var prembarx = new array (4);
Var prembary = new array (4);
VAR CX = Math.Round ((BX [0] BX [1] BX [2] BX [3]) / 4);
Var cy = math.Round ((by [0] by [1] by [2] by [3]) / 4); for (i = 0; i <4; i ) {
Prembarx [i] = Math.Round (CX-CY by [i]);
Prembary [i] = math.Round (CX CY-BX [I]);
IF (PrembarX [i] <0 || prembarx [i]> 9 || prembary [i] <0 || prembary [i]> 15) Return;
IF (PREMBARX [I], Prembary [I]) == "SB") Return;
}
For (i = 0; i <4; i ) setClass (BX [i], by [i], "bk");
For (i = 0; i <4; i ) {
BX [i] = prembarx [i];
BY [I] = prembary [i];
}
For (i = 0; i <4; i ) setClass (BX [i], by [i], "mb");
Break;
Case 39: {// Right
For (i = 0; i <4; i ) IF (bx [i] == 9) return;
For (i = 0; i <4; i ) IF (GetClass (BX [I] 1, by [i]) == "SB") Return;
For (i = 0; i <4; i ) setClass (BX [i], by [i], "bk");
For (i = 0; i <4; i ) bx [i] = bx [i] 1;
For (i = 0; i <4; i ) setClass (BX [i], by [i], "mb");
Break;
Case 40: {// Down
Movebar ();
Break;
}
}
Function Delline ()
{
For (i = 0; i <4; i ) setClass (BX [I], BY [I], "SB");
For (j = 0; j <16; j ) {
DLINE = TRUE;
For (i = 0; i <9; i ) {
IF (GetClass (i, j)! = "sb") {
DLINE = FALSE;
Break;
}
}
IF (DLINE) {
Score = score 100;
For (k = j; k> 0; k -)
For (l = 0; l <10; l )
SetClass (L, K, GetClass (L, K-1));
For (l = 0; l <10; l ) setClass (L, 0, "BK");
}
}
Randbar ();
Speed = Math.floor (score / 3000) 1;
Outtime = 1100-speted * 100;
Scorebar.innerhtml = "score:" score;
SpeedBar.innerHtml = "Speed:" Speed;
WINDOW.CLARINTERVAL (Mtimer);
Mtimer = Window.setInterval ("MoveBar ()", Outtime;
}
Function getClass (x, y) {return gamebar.children [y] .children [x] .classname;} Function setClass (x, y, cname) {gamebar.children [y] .children [x] .classname = cname; }
Function movebar ()
{
IF (GameState! = 1) Return;
Dropline = True;
For (i = 0; i <4; i ) IF (by [i] == 15) Dropline = FALSE;
IF (Dropline) for (i = 0; i <4; i ) IF (getClass (BX [i], by [i] 1) == "SB") Dropline = false;
IF (! dropline) {
WINDOW.CLARINTERVAL (Mtimer);
Delline ();
Return;
}
For (i = 0; i <4; i ) setClass (BX [i], by [i], "bk");
For (i = 0; i <4; i ) by [i] = by [i] 1;
For (i = 0; i <4; i ) setClass (BX [i], by [i], "mb");
}
Function pausegame ()
{
IF (GameState == 0) Return;
IF (event.srcelement.value == "pause") {
Gamestate = 2;
Event.srcelement.value = "continue";
WINDOW.CLARINTERVAL (Mtimer);
}
Else {
Gamestate = 1;
Event.srcelement.value = "pause";
Mtimer = Window.setInterval ("MoveBar ()", Outtime;
}
}
Function FMNU () {RETURN FALSE;}
Document.οncοntextMenu = FMNU;
Function preview ()
{
IF (previewBar.Style.Display! = "none")
PreviewBar.Style.display = "none";
Else
PreviewBar.Style.display = "block";
}
Function replayGame ()
{
IF (GameState! = 1) Return;
IF (! "" "))).
Gamestate = 0;
WINDOW.CLARINTERVAL (Mtimer);
Beguingame ();
}
Function randbar ()
{
RandNum = Math.floor (Math.random () * 20) 1;
IF (! firstview)
For (i = 0; i <4; i ) {
BX [i] = px [i];
By [i] = py [i];
}
Switch (randnum) {
Case 1: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 4;
Py [1] = 1;
PX [2] = 5;
Py [2] = 1;
PX [3] = 6;
Py [3] = 1;
Break;} case 2: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 5;
PY [1] = 0;
PX [2] = 4;
Py [2] = 1;
PX [3] = 4;
Py [3] = 2;
Break;
Case 3: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 5;
PY [1] = 0;
PX [2] = 6;
PY [2] = 0;
PX [3] = 6;
Py [3] = 1;
Break;
Case 4: {
PX [0] = 5;
PY [0] = 0;
PX [1] = 5;
Py [1] = 1;
PX [2] = 5;
Py [2] = 2;
PX [3] = 4;
Py [3] = 2;
Break;
Case 5: {
PX [0] = 6;
PY [0] = 0;
PX [1] = 6;
Py [1] = 1;
PX [2] = 4;
Py [2] = 1;
PX [3] = 5;
Py [3] = 1;
Break;
Case 6: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 4;
Py [1] = 1;
PX [2] = 4;
Py [2] = 2;
PX [3] = 5;
Py [3] = 2;
Break;
Case 7: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 4;
Py [1] = 1;
PX [2] = 5;
PY [2] = 0;
PX [3] = 6;
Py [3] = 0;
Break;
Case 8: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 5;
Py [1] = 0;
PX [2] = 5;
Py [2] = 1;
PX [3] = 5;
Py [3] = 2;
Break;
Case 9: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 5;
Py [1] = 0;
PX [2] = 5;
Py [2] = 1;
PX [3] = 6;
Py [3] = 1;
Break;
Case 10: {
PX [0] = 5;
PY [0] = 0;
PX [1] = 5;
Py [1] = 1;
PX [2] = 4;
Py [2] = 1;
PX [3] = 4;
Py [3] = 2;
Break;
Case 11: {
PX [0] = 4;
PY [0] = 1;
PX [1] = 5;
Py [1] = 1;
PX [2] = 5;
PY [2] = 0;
PX [3] = 6;
Py [3] = 0;
Break;
Case 12: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 4;
Py [1] = 1;
PX [2] = 5;
Py [2] = 1;
PX [3] = 5;
Py [3] = 2;
Break;
Case 13: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 5;
Py [1] = 0;
PX [2] = 6;
PY [2] = 0;
PX [3] = 5;
Py [3] = 1;
Break;
Case 14: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 4;
Py [1] = 1;
PX [2] = 4;
Py [2] = 2;
PX [3] = 5;
Py [3] = 1;
Break;
Case 15: {
PX [0] = 5;
Py [0] = 0; PX [1] = 5;
Py [1] = 1;
PX [2] = 4;
Py [2] = 1;
PX [3] = 6;
Py [3] = 1;
Break;
Case 16: {
PX [0] = 5;
PY [0] = 0;
PX [1] = 5;
Py [1] = 1;
PX [2] = 5;
Py [2] = 2;
PX [3] = 4;
Py [3] = 1;
Break;
Case 17: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 5;
Py [1] = 0;
PX [2] = 4;
Py [2] = 1;
PX [3] = 5;
Py [3] = 1;
Break;
Case 18: {
PX [0] = 4;
PY [0] = 0;
PX [1] = 5;
Py [1] = 0;
PX [2] = 4;
Py [2] = 1;
PX [3] = 5;
Py [3] = 1;
Break;
Case 19: {
PX [0] = 3;
PY [0] = 0;
PX [1] = 4;
Py [1] = 0;
PX [2] = 5;
PY [2] = 0;
PX [3] = 6;
Py [3] = 0;
Break;
Case 20: {
PX [0] = 5;
PY [0] = 0;
PX [1] = 5;
Py [1] = 1;
PX [2] = 5;
Py [2] = 2;
PX [3] = 5;
Py [3] = 3;
Break;
}
IF (firstview) {
FigStview = false;
Randbar ();
Return;
}
For (i = 0; i <4; i ) {
For (j = 0; j <4; j ) {
PreviewBar.children [J] .Children [i] .classname = "bk";
}
}
For (i = 0; i <4; i ) previewbar.children [py [i]]. Children [PX [i] -3] .className = "MB";
For (i = 0; i <4; i ) {
IF (GetClass (BX [I], by [i])! = "bk") {
Alert ("Game Over!");
WINDOW.CLARINTERVAL (Mtimer);
Play.disabled = false;
Gamestate = 0;
Return;
}
}
For (i = 0; i <4; i ) setClass (BX [i], by [i], "mb");
}
// ->
script>
HEAD>
Russian square font> b> p>
TD> | TD> | TD> | TD> | < / TD> | TD> | TD> | TD> | < / TD> tr> | |||||||||||||||||||||||||||||
td> | td> | td> | td> | TD> | TD> | TD> | TD> | TD> | TD> TD Class = BK> TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> TD Class = BK> TD> | TD> | td> | td> | td> | td> | td> | td> | TD> | TD> | TD> | TD > | TD> | TD> | TD> | TD> | TD > <
TD class = BK> td> | td> | td> tr> | |
td> | td> | td> | td> | td> | td> | td> | td> | td> | td> tr> | ||||||||||||||||||||||||||||
< / TD> | TD> | TD> | TD> | < / TD> | TD> | TD> | TD> | TD> TR> | |||||||||||||||||||||||||||||
TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> tr> | ||||||||||||||||||||||||||||
TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | td> tr> | ||||||||||||||||||||||||||||
td> | td> | td> | td> <
TD Class = BK> TD> | TD> | TD> | TD> | TD> < TD class = BK> td> tr> | ||||||||||||||||||||||||||||||
td> | td> | td> | td> | td> | td> | td> | td> | td> | td> tr> | ||||||||||||||||||||||||||||
td> | td> | < / TD> | TD> | TD> | TD> | < / TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TR> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> | TD> TR> | |||||||||
td> <
TD Class = BK> TD> | TD> | TD> | TD> | TD> < TD Class = BK> TD> | TD> | TD> | TR> | ||||||||||||||||||||||||||||||
td> | td> | td> | td> | td> | TD> | TD> | TD> | TD> | TD> TR> tbody>
TABLE> center>
|