俄罗斯方块java(4)

2021-04-05 02:40

俄罗斯方块java

id*iWidthGrid][2];
//转换,把方块内有效部分的坐标都转换成容器内的坐标,然后返回.
for(int i=0;i<iHeightGrid;i++)
for(int j=0;j<iWidthGrid;j++)
if(aryDiamonds[i][j]==1)
{
rtnRowColNos[i*iWidthGrid+j][0]=referPoint[0]+i;
rtnRowColNos[i*iWidthGrid+j][1]=referPoint[1]+j;
}
else //把方块中不用显示的部分的行号和列号设为-1,便于区分.
{
rtnRowColNos[i*iWidthGrid+j][0]=-1;
rtnRowColNos[i*iWidthGrid+j][1]=-1;
}

return(rtnRowColNos);
}

//返回判定向左移动时判定接触的方块部分的行号和列号,数组中元素存放的顺序无要求.
public int[][] leftTouchGrids()
{
int[][] rtnRowColNos=new int[iHeightGrid][2]; //第1维是接触面所占格子的数量,第2维的第1,2个元素是格子相对于容器的坐标.
//这里默认方块的接触面是连续的没有空缺.
for(int i=0;i<iHeightGrid;i++)
{
for(int j=0;j<iWidthGrid;j++)
{
if(aryDiamonds[i][j]==1)
{
rtnRowColNos[i][0]=referPoint[0]+i;
rtnRowColNos[i][1]=referPoint[1]+j;
break;
}
}
}


/*只适合方块5的代码.
if(iSortNo==5)
{
rtnRowColNos[0][0]=referPoint[0];
rtnRowColNos[0][1]=referPoint[1];
rtnRowColNos[1][0]=referPoint[0];
rtnRowColNos[1][1]=referPoint[1]+1;
}*/

return rtnRowColNos;
}

//返回判定向右移动时判定接触的方块部分的坐标
public int[][] rightTouchGrids()
{
int[][] rtnRowColNos=new int[iHeightGrid][2];
for(int i=0;i<iHeightGrid;i++)
{
for(int j=iWidthGrid-1;j>=0;j--)
{
if(aryDiamonds[i][j]==1)
{
rtnRowColNos[i][0]=referPoint[0]+i;
rtnRowColNos[i][1]=referPoint[1]+j;
break;
}
}
}

return rtnRowColNos;
}

//返回判定向下移动时判定接触的方块部分的坐标
public int[][] downTouchGrids()
{
int[][] rtnRowColNos=new int[iWidthGrid][2];
for(int i=0;i<iWidthGrid;i++)
{
for(int j=0;j<iHeightGrid;j++)
{
if(aryDiamonds[j][i]==1)
{
rtnRowColNos[i][0]=referPoint[0]+j;
rtnRowColNos[i][1]=referPoint[1]+i;
break;
}
}
}

return rtnRowColNos;
}

public void initDiamondsTable()
{
diamondsTable=new int[SORTNUM][];
diamondsTable[0]=new int[2];
diamondsTable[1]=new int[4];
diamondsTable[2]=new int[4];
diamondsTable[3]=new int[2];
diamondsTable[4]=new int[2];
diamondsTab
le[5]=new int[1];
diamondsTable[6]=new int[4];

//存放各种方块旋转后的下一个状态号.
for(int i=0;i<diamondsTable.length;i++)
for(int


俄罗斯方块java(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2013-2014年北京市昌平区2014年中考一模数学试卷(含答案)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: