}
}
//添加元素
this.addElement=function(el)
{
//得到起始元素的X开始坐标和Y开始坐标的位置(错误)
//得到X坐标的下落次数,和Y轴的左右移动的次数
var xBegin=parseInt(el.offsetLeft/unit);
var yBegin=parseInt(el.offsetTop/unit);
if(xBegin>=0&&xBegin<=this.x&&yBegin>=0&&yBegin<=this.y)
{
this.board[yBegin][xBegin]=el; //确定元素的位置
}
}
//消掉所有的行
this.removeFullLines=function()
{
var lines=0;
for(var i=this.y-1;i>0;i--)
{
if(this.linesRelated(i))
{
this.removeLines(i);
lines++;
y++;
}
}
return lines; //返回线条
}
//和线性有关的东西(判断是否满了)
this.linesRelated=function(y)
{
for(var x=0;x<this.x;x++)
{
if(!this.board[y][x]){return false;} //如果不为0的话,那么菜返回FALSE
}
return true;
};
//去掉行
this.removeLines=function(y)
{
for(var x=0;x<this.x;x++)
{
this.el.removeChild(this.board[y][x]);
this.board[y][x]=0;
}
y--;
for(;y>0;y--)
{
/*今天暂时写到这里*/
/*继续于2014-12-21*/
for(var x=0;x<this.x;x++)
{
if(this.board[y][x])
{
var el=this.board[y][x];
el.style.top=el.offsetTop+this.unit+"px";
this.board[y+1][x]=el;
this.board[y][x]=0;
}
}
}
};
//活动区域
this.getBlock=function(y,x)
{
if(y<0){return 0;}
if(y<this.y&&x<this.x)
{
return this.board[y][x];
}
else