java版的俄罗斯方块问题.定义方块的形状那个数组和生成新方块的方法没看懂,
// 方块的形状 第一组代表方块类型有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 } }
};
// 生成新方块的方法
public void newblock() {
blockType = (int) (Math.random() * 1000) % 7;
turnState = (int) (Math.random() * 1000) % 4;
x = 4;
y = 0;
if (gameover(x,y) == 1) {
newmap();
drawwall();
score = 0;
JOptionPane.showMessageDialog(null,"GAME OVER");
}
}
作业帮用户2017-09-22举报