我正在开发一款俄罗斯方块游戏,并在xml文件中保存以下格式的区块地图。
<block column="2">101011</block>然后,im将该xml解析为一维数组,如下所示
boolean[] bitmap=new boolean[]{true,false,true,false,true,true};// java中布尔值中的101011
然后,在绘制俄罗斯方块时,im使用列号和这个一维数组来计算每个块的坐标。然后显示"L“块
10
10
11
现在..。我想旋转这些块..。我需要做的是:(对于ccw)
101011
至
001111
和列号2到3
发布于 2012-03-07 19:04:44
尝试使用此代码遍历2dD数组,以便创建所需的1D数组:
int[][] array = new int[][] { { 1, 0 }, { 1, 0 }, { 1, 1 } };
int[] newArray = new int[6];
int index = 0;
// Populating 1D array.
for (int i = array[0].length; i > 0; i--)
for (int j = 0; j < array.length; j++)
newArray[index++] = array[j][i - 1];
// See the contents of 1D array.
for (int i = 0; i < newArray.length; i++)
System.out.println(newArray[i]);https://stackoverflow.com/questions/9599764
复制相似问题