日期:2009-06-23  浏览次数:20863 次

var Cols = 10, Rows = 20, Sqlen = 16;
var Color = new Array(8);
var delLine = new Array();

var CLoc = new Array();
var RLoc = new Array();
var CurSq,NextSq;
var type=-1,oldtype;
var delay = new Array(600,500,400,300,200,100,90,80,70);
var TimerID;
var pos = 0,end,level=0,score=0,lines=0;
var isOver=false,isPause=false;

Color[0] = "#d0d0d0";
Color[1] = "red";
Color[2] = "green"
Color[3] = "cyan";
Color[4] = "yellow";
Color[5] = "orange";
Color[6] = "pink";
Color[7] = "blue";


function GameArea(row,col,name){
var s = "<TABLE BORDER=1 cellspacing=0 cellpadding=1 bgcolor=" + Color[0] + ">";
for(var i=0; i<row; i++){
  s = s + "<TR Height=" + Sqlen + ">";
  for(var j=0; j<col; j++){
   var id = name + i + "#" + j;
   s = s + "<TD Width=" + Sqlen + " class=btnup id=" + id;
   s = s + " style=\"background:" + Color[0] + "\"> </TD>"
  }
  s = s + "</TR>";
}
s = s + "</TABLE>";
return s;
}

function Init(){
GameBody.innerHTML = GameArea(Rows,Cols,'Main');
GameForecast.innerHTML = GameArea(4,4,'Forecast');
}

function Square(cols,rows,color){
this.rows = rows;
this.cols = cols;
this.color = color;
}

function chooseSquare(type,x,y){
var sq = new Array(4);
switch(type){
  case 0:
   sq[0] = new Square(x-1,y,1);
   sq[1] = new Square(x,y,1);
   sq[2] = new Square(x+1,y,1);
   sq[3] = new Square(x+2,y,1);
   break;
  case 1:
   sq[0] = new Square(x,y,5);
   sq[1] = new Square(x,y+1,5);
   sq[2] = new Square(x+1,y+1,5);
   sq[3] = new Square(x,y+2,5);
   break;
  case 2:
   sq[0] = new Square(x,y,2);
   sq[1] = new Square(x,y+1,2);
   sq[2] = new Square(x+1,y+1,2);
   sq[3] = new Square(x+1,y+2,2);
   break;
  case 3:
   sq[0] = new Square(x+1,y,7);
   sq[1] = new Square(x+1,y+1,7);
   sq[2] = new Square(x,y+1,7);
   sq[3] = new Square(x,y+2,7);
   break;
  case 4:
   sq[0] = new Square(x,y,3);
   sq[1] = new Square(x+1,y,3);
   sq[2] = new Square(x,y+1,3);
   sq[3] = new Square(x+1,y+1,3);
   break;
  case 5:
   sq[0] = new Square(x,y,6);
   sq[1] = new Square(x+1,y,6);
   sq[2] = new Square(x+1,y+1,6);
   sq[3] = new Square(x+1,y+2,6);
   break;
  case 6:
   sq[0] = new Square(x+1,y,4);
   sq[1] = new Square(x,y,4);
   sq[2] = new Square(x,y+1,4);
   sq[3] = new Square(x,y+2,4);
   break;
}
return sq;
}

function reDraw