JAVA俄罗斯方块,里面的数字0,看不懂啊.// 方块的形状 第一组代表方块类型有S、Z、L、J、I、O、T 7种 第二组 代表旋转几次 第三四组为 方块矩阵private final int shapes[][][] = new int[][][] {// i{ { 0,0,0,0
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 14:43:44
JAVA俄罗斯方块,里面的数字0,看不懂啊.// 方块的形状 第一组代表方块类型有S、Z、L、J、I、O、T 7种 第二组 代表旋转几次 第三四组为 方块矩阵private final int shapes[][][] = new int[][][] {// i{ { 0,0,0,0
JAVA俄罗斯方块,里面的数字0,看不懂啊.
// 方块的形状 第一组代表方块类型有S、Z、L、J、I、O、T 7种 第二组 代表旋转几次 第三四组为 方块矩阵
private final int shapes[][][] = new int[][][] {
// i
{ { 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0 },
{ 0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0 },
{ 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0 },
{ 0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0 } },
// s
{ { 0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0 },
{ 1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0 },
{ 0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0 },
{ 1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0 } },
// z
{ { 1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
{ 0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0 },
{ 1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
{ 0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0 } },
// j
{ { 0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0 },
{ 1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0 },
{ 1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0 },
{ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0 } },
// o
{ { 1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0 },
{ 1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0 },
{ 1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0 },
{ 1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0 } },
// l
{ { 1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0 },
{ 1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0 },
{ 1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0 },
{ 0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0 } },
// t
{ { 0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0 },
{ 0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0 },
{ 1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0 },
{ 0,1,0,0,0,1,1,0,0,1,0,0,0,0,0,0 } } };
// 生成新方块的方法
JAVA俄罗斯方块,里面的数字0,看不懂啊.// 方块的形状 第一组代表方块类型有S、Z、L、J、I、O、T 7种 第二组 代表旋转几次 第三四组为 方块矩阵private final int shapes[][][] = new int[][][] {// i{ { 0,0,0,0
0代表是没小方块的,1代表是有小方块 (我把这里看成是每个方块是有小方块组成)
你可以把矩阵这样看
0 0 0 0
1 1 1 1
0 0 0 0
0 0 0 0
0 1 0 0
0 1 0 0
0 1 0 0
0 1 0 0
上面的数字1的连线不就是 一形状的两种形态吗
其他如此类推