您的当前位置:首页Block

Block

2020-02-29 来源:飒榕旅游知识分享网
package day;

import java.awt.*;

import java.awt.event.*; import java.util.Random; import javax.swing.*;

public class Block extends JPanel implements ActionListener,KeyListener//继承动作监听器类和键盘监听器类 {

private static final long serialVersionUID = 1L;

static Button but[] = new Button[6];

static Button noStop = new Button(\"取 消 暂 停\");

static Label scoreLab = new Label(\"分数:\"); static Label infoLab = new Label(\"提示:\"); static Label speedLab = new Label(\"级数:\"); static Label scoreTex = new Label(\"0\"); static Label infoTex = new Label(\"游戏还未开始! \");

static Label speedTex = new Label(\"1\");

static JFrame jf = new JFrame(); static MyTimer timer;

static JMenu menu0 = new JMenu(\"游戏 \"); static JMenu menu1 = new JMenu(\"帮助 \");

static JMenuItem mi0 = new JMenuItem(\"开始 游 戏\");

static JMenuItem mi0_1 = new JMenuItem(\"退出游戏\");

static JMenuItem mi1_0 = new JMenuItem(\"关于\");

static JMenuBar mb = new JMenuBar();

static int startSign = 0;//游戏开始标志 0 未开始 1 开始 2 暂停

static String butLab[] = {\"开 始 游 戏\重 新 开 始\降 低 级 数\提 高 级 数\游 戏 暂 停\退 出 游 戏\

static int game_body[][] = new int[19][10]; static int game_sign_x[] = new int[4];//用于记录4个方格的水平位置

static int game_sign_y[] = new int[4];//用于记录4个方格的垂直位置

static boolean downSign = false;//是否落下 static int blockNumber = 1;//砖块的编号 static int gameScore = 0;//游戏分数 static int speedMark = 1;

static int line=0;//消去的行数

//主方法main设置主窗体,以及启动线程

public static void main(String args[]) {

Block myBlock = new Block(); mb.add(menu0); mb.add(menu1); menu0.add(mi0); menu0.add(mi0_1); menu1.add(mi1_0); jf.setJMenuBar(mb);

jf.setBackground(Color.gray); myBlock.init();

jf.add(myBlock);

jf.setSize(565,501); jf.setResizable(false); jf.setTitle(\"俄罗斯方块\");

jf.setLocation(200,100); jf.show();

timer = new MyTimer(myBlock); //启动线程 timer.setDaemon(true); timer.start();//线程启动 timer.suspend(); }

//初始化方法,主要设置布局(按钮,文本框等),以及添加监听

public void init() {

setLayout(null);

for(int i = 0;i < 6;i++) {

but[i] = new Button(butLab[i]); add(but[i]);

but[i].addActionListener(this); but[i].addKeyListener(this);

but[i].setBounds(360,(240 + 30 * i),160,25); }

add(scoreLab); add(scoreTex); add(speedLab); add(speedTex); add(infoLab); add(infoTex); add(scoreLab);

scoreLab.setBounds(320,15,30,20); scoreTex.setBounds(360,15,160,20); scoreTex.setBackground(Color.white); speedLab.setBounds(320,45,30,20); speedTex.setBounds(360,45,160,20); speedTex.setBackground(Color.white);

but[1].setEnabled(false); but[4].setEnabled(false);

infoLab.setBounds(320,75,30,20); infoTex.setBounds(360,75,160,20); infoTex.setBackground(Color.white); noStop.setBounds(360,360,160,25); noStop.addActionListener(this); noStop.addKeyListener(this); mi0.addActionListener(this); mi0_1.addActionListener(this); mi1_0.addActionListener(this); //数组清零

num_csh_game(); //随机产生方块的方法 rand_block(); }

//监听方法

public void actionPerformed(ActionEvent e) {

//如果按了开始游戏的键,需要重启线程 if(e.getSource() == but[0]) {

//按了开始后把startSign = 1 startSign = 1;

infoTex.setText(\"游戏已经开始!\"); but[0].setEnabled(false);

but[1].setEnabled(true); but[4].setEnabled(true); //重启线程

timer.resume(); }

//如果按了重新开始游戏的键

if(e.getSource() == but[1]||e.getSource() == mi0) {

startSign = 0; gameScore = 0; timer.suspend(); num_csh_restart(); //重画方块 repaint(); rand_block();

scoreTex.setText(\"0\");

infoTex.setText(\"新游戏!\"); but[0].setEnabled(true); but[1].setEnabled(false); but[4].setEnabled(false); }

//如果按了降低级数的键

if(startSign==0){//当游戏还未开始时才可以设置级数

if(e.getSource() == but[2]) {

infoTex.setText(\"降低级数!\"); speedMark--;

if(speedMark <= 1) {

speedMark = 1;

infoTex.setText(\"已经是最低级数!\"); }

speedTex.setText(speedMark + \"\"); } }

//如果按了提高级数的键

if(startSign==0){//当游戏还未开始时才可以设置级数

if(e.getSource() == but[3]) {

infoTex.setText(\"提高级数!\"); speedMark++;

if(speedMark >= 10) {

speedMark = 10;

infoTex.setText(\"已经是最高级数!\"); }

speedTex.setText(speedMark + \"\"); } }

//游戏暂停,需要暂停线程

if(e.getSource() == but[4]) {

this.add(noStop); this.remove(but[4]);

infoTex.setText(\"游戏暂停!\"); //暂停线程

timer.suspend(); }

//取消暂停,需要重启线程

if(e.getSource() == noStop) {

this.remove(noStop); this.add(but[4]);

infoTex.setText(\"继续游戏!\"); //重启线程

timer.resume(); }

//退出游戏

if(e.getSource() == but[5]||e.getSource() == mi0_1) {

//确认对话框 int

val=JOptionPane.showConfirmDialog(jf, \"确认离开?\离开系统\ if(val==JOptionPane.YES_OPTION){ System.exit(0);//离开系统 } }

if(e.getSource() == mi1_0)//关于 {

JOptionPane.showMessageDialog(jf, \"当玩家控制的下落图形填满横向一行所有空格时,本行自动消除,得五分!\"); } }

//随机产生砖块的方法

public void rand_block() {

Random r=new Random(); int num;

num = r.nextInt(7);//产生0~6之间的随机数 blockNumber = num; switch(blockNumber) {

case 0: block1(); blockNumber = 1; break; case 1: block2(); blockNumber = 2; break; case 2: block3(); blockNumber = 3; break; case 3: block4(); blockNumber = 4; break;

case 4: block5(); blockNumber = 5; break; case 5: block6(); blockNumber = 6; break; case 6: block7(); blockNumber = 7; break; } }

public void block1()//长条 {

game_body[0][4] = 1; game_body[1][4] = 1; game_body[2][4] = 1; game_body[3][4] = 1; }

public void block2()//田形 {

game_body[3][4] = 1; game_body[2][4] = 1; game_body[3][5] = 1; game_body[2][5] = 1; }

public void block3() // L型 {

game_body[1][4] = 1; game_body[2][4] = 1; game_body[3][4] = 1; game_body[3][5] = 1; }

public void block4()//一竖加一横(一横在一竖的右边) {

game_body[1][4] = 1; game_body[2][4] = 1; game_body[3][4] = 1;

game_body[2][5] = 1; }

public void block5()//7关于Y轴对称后的图形 {

game_body[1][4] = 1; game_body[2][4] = 1; game_body[3][4] = 1; game_body[1][5] = 1; }

public void block6()//Z逆时针旋转90度后的图形

{

game_body[1][5] = 1; game_body[2][5] = 1; game_body[2][4] = 1; game_body[3][4] = 1; }

public void block7()//Z关于Y轴对称后的图形 {

game_body[1][4] = 1; game_body[2][4] = 1; game_body[2][5] = 1; game_body[3][5] = 1; }

//画方块的方法

public void paint(Graphics g) {

g.setColor(Color.black);

g.fill3DRect(0,0,300,450,true);

for(int i = 0;i < 19;i++)

{

for(int j = 0;j < 10;j++) {

if(game_body[i][j] == 1) {

g.setColor(Color.blue);

g.fill3DRect(30*j,30*(i-4),30,30,true); }

if(game_body[i][j] == 2) {

g.setColor(Color.magenta);

g.fill3DRect(30*j,30*(i-4),30,30,true); } } } }

//给已经落下的块换色

public void changeColor() {

downSign = false;

for(int k = 0;k < 4;k++) {

game_body[game_sign_y[k]][game_sign_x[k]] = 2;

} }

//确定四个方块的X,Y坐标位置 public void dingwei() {

int k = 0;

//将定位数组初始化 cancelDW();

for(int i = 0;i < 19;i++) {

for(int j = 0;j < 10;j++) {

if(game_body[i][j] == 1) {

game_sign_x[k] = j; game_sign_y[k] = i; k++; } } } }

//将定位数组初始化

public void cancelDW() {

for(int k = 0;k < 4;k++) {

game_sign_x[k] = 0; game_sign_y[k] = 0; } }

//数组清零,下落后的数组不清除 public void num_csh_game() {

for(int i = 0;i < 19;i++) {

for(int j = 0;j < 10;j++) {

if(game_body[i][j] == 2) {

game_body[i][j]=2; }

else {

game_body[i][j] = 0; } } } }

//重新开始时数组清零

public void num_csh_restart() {

for(int i = 0;i < 19;i++) {

for(int j = 0;j < 10;j++) {

game_body[i][j] = 0; } } }

//判断游戏是否结束的方法,如果顶层有下落固定后的方块即结束游戏(一个或是有多个都结束) public boolean game_over() {

int sign=0;

for(int i = 0;i < 10;i++) {

if(game_body[4][i] == 2) {

sign = 1; } }

if(sign == 1) {

infoTex.setText(\"游戏结束!\"); changeColor();

repaint();

startSign = 0; //暂停线程

timer.suspend(); return true; } else

return false; }

public void xiaohang()//满行消除并设置分数的方法 {

for(int i = 0;i < 19;i++) {

//判断一行中有几个已经下落的格子 int sign = 0;

for(int j = 0;j < 10;j++) {

//如果一行中已满10格子把sign++ if(game_body[i][j] == 2) {

sign++; } }

//如果一行中满了10个格子,即得5分,如果分数能被100整除,则提高级数 if(sign == 10) {

line++;

//满了10个后消行

for(int j = i;j >= 1;j--) {

for(int k = 0;k < 10;k++)

{

game_body[j][k] = game_body[j - 1][k];

} } } } }

public void getScore(){ if(line>=1){

gameScore= gameScore+5*line; scoreTex.setText(gameScore+\"\"); infoTex.setText(\"恭喜得分!\"); line=0;

//如果分数能被100整除,则提高级数,但至多到10级

if(gameScore%5==0){ if(speedMark<=9){ speedMark++;

speedTex.setText(speedMark+\"\");

num_csh_restart(); line=0;

startSign = 1;

infoTex.setText(\"游戏已经开始!\"); but[0].setEnabled(false); but[1].setEnabled(true); but[4].setEnabled(true); //重启线程

timer.resume(); }

} } }

public void keyTyped(KeyEvent e){} public void keyReleased(KeyEvent e){} public void keyPressed(KeyEvent e) {

if(e.getKeyCode() == KeyEvent.VK_DOWN&&startSign == 1)//处理下键 {

this.down(); }

if(e.getKeyCode() == KeyEvent.VK_LEFT&&startSign == 1)//处理左键 {

this.left(); }

if(e.getKeyCode() == KeyEvent.VK_RIGHT&&startSign == 1)//处理右键 {

this.right(); }

if(e.getKeyCode() == KeyEvent.VK_UP&&startSign == 1)//处理上键转换 {

this.change_body(blockNumber); }

if(startSign == 0) {

infoTex.setText(\"游戏已结束!\"); }

}

//向左移动的方法

public void left() {

int sign = 0; dingwei();

for(int k = 0;k < 4;k++) {

if(game_sign_x[k] == 0||game_body[game_sign_y[k]][game_sign_x[k] - 1] == 2) {

sign = 1; } }

if(sign == 0&&downSign == false) {

num_csh_game();

for(int k = 0;k < 4;k++) {

game_body[game_sign_y[k]][game_sign_x[k] - 1] = 1;

}

infoTex.setText(\"向左移动!\"); repaint(); } }

//向右移动的方法

public void right() {

int sign = 0; dingwei();

for(int k = 0;k < 4;k++)

{

if(game_sign_x[k] == 9||game_body[game_sign_y[k]][game_sign_x[k] + 1] == 2) {

sign = 1; } }

if(sign == 0&&downSign == false) {

num_csh_game();

for(int k = 0;k < 4;k++) {

game_body[game_sign_y[k]][game_sign_x[k] + 1] = 1;

}

infoTex.setText(\"向右移动!\"); repaint(); } }

//下落的方法

public void down() {

int sign = 0; dingwei();

for(int k = 0;k < 4;k++) {

if(game_sign_y[k] 18||game_body[game_sign_y[k] 1][game_sign_x[k]] == 2) {

sign = 1;

downSign = true; changeColor();

== + cancelDW(); xiaohang(); getScore();

if(game_over() == false) {

rand_block(); repaint(); } } }

if(sign == 0) {

num_csh_game();

for(int k = 0;k < 4;k++) {

game_body[game_sign_y[k] + 1][game_sign_x[k]] = 1; }

infoTex.setText(\"游戏进行中!\"); repaint(); } }

//改变砖块状态,即旋转方块的方法,键盘中箭头向上按动表示旋转

public void change_body(int blockNumber) {

dingwei();

if(blockNumber == 1&&downSign == false)//变换长条2种情况 {

if(game_sign_y[0] == game_sign_y[1]&&game_sign_y[3] <= 16)//说明长条是横着的 {

if(game_body[game_sign_y[0] - 1][game_sign_x[0] + 1] != 2&&game_body[game_sign_y[3] + 2][game_sign_x[3] - 2] != 2) {

num_csh_game();

game_body[game_sign_y[0] - 1][game_sign_x[0] + 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1]] = 1; game_body[game_sign_y[2] + 1][game_sign_x[2] - 1] = 1;

game_body[game_sign_y[3] + 2][game_sign_x[3] - 2] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_x[0] == game_sign_x[1]&&game_sign_x[0] >= 1&&game_sign_x[3] <= 7)//说明长条是竖着的 {

if(game_body[game_sign_y[0] + 1][game_sign_x[0]-1] != 2&&game_body[game_sign_y[3] - 2][game_sign_x[3] + 2] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1]]=1; game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] = 1;

game_body[game_sign_y[3] -

2][game_sign_x[3] + 2] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } } }

if(blockNumber == 3&&downSign == false)//变换转弯1有4种情况 {

if(game_sign_x[0] == game_sign_x[1]&&game_sign_x[0] == game_sign_x[2]&&game_sign_y[2] == game_sign_y[3]&&game_sign_x[0] >= 1) {

if(game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] != 2&&game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] !=

2&&game_body[game_sign_y[3] - 2][game_sign_x[3]] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1]] = 1; game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] = 1;

game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_y[1] ==

game_sign_y[2]&&game_sign_y[2] == game_sign_y[3]&&game_sign_x[0] == game_sign_x[3]&&game_sign_y[1] <= 17) {

if(game_body[game_sign_y[0]][game_sign_x[0] - 2] != 2&&game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] != 2&&game_body[game_sign_y [3] - 1][game_sign_x[3] - 1] != 2)

{

num_csh_game();

game_body[game_sign_y[0]][game_sign_x[0] - 2] = 1;

game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1;

game_body[game_sign_y[2]][game_sign_x[2]] = 1; game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] = 1;

infoTex.setText(\"游戏进行中!\");

repaint(); } }

if(game_sign_x[1] == game_sign_x[2]&&game_sign_x[1] == game_sign_x[3]&&game_sign_y[0] == game_sign_y[1]&&game_sign_x[3] <= 8) {

if(game_body[game_sign_y[0] + 2][game_sign_x[0]] != 2&&game_body[game_sign_y[1] + 1][game_sign_x[1]

- 1] !=

2&&game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1;

game_body[game_sign_y[1] + 1][game_sign_x[1] - 1] = 1;

game_body[game_sign_y[2]][game_sign_x[2]] = 1; game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_y[0] == game_sign_y[1]&&game_sign_y[1] == game_sign_y[2]&&game_sign_x[0] == game_sign_x[3]) {

if(game_body[game_sign_y[0] + 1][game_sign_x[0] + 1] != 2&&game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] != 2&&game_body

[game_sign_y[3]][game_sign_x[3] + 2] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 1][game_sign_x[0] + 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1]] = 1; game_body[game_sign_y[2] -

1][game_sign_x[2] - 1] = 1;

game_body[game_sign_y[3]][game_sign_x[3] + 2] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } } }

if(blockNumber == 4&&downSign == false)//变换转弯2有4种情况 {

if(game_sign_x[0] == game_sign_x[1]&&game_sign_x[0] == game_sign_x[3]&&game_sign_y[1] == game_sign_y[2]&&game_sign_x[3] <= 7) {

if(game_body[game_sign_y[0] + 2][game_sign_x[0]] != 2&&game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] !=

2&&game_body[game_sign_y[3]][game_sign_x[3] + 2] != 2)

{

num_csh_game();

game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1;

game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1;

game_body[game_sign_y[2]][game_sign_x[2]] = 1;

game_body[game_sign_y[3]][game_sign_x[3] + 2] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_y[1] == game_sign_y[2]&&game_sign_y[1] == game_sign_y[3]&&game_sign_x[0] == game_sign_x[2]) {

if(game_body[game_sign_y[1]][game_sign_x[1] + 2] != 2&&game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] !=

2&&game_body[game_sign_y[3] - 2][game_sign_x[3]] != 2) {

num_csh_game();

game_body[game_sign_y[0]][game_sign_x[0]] = 1;

game_body[game_sign_y[1]][game_sign_x[1] + 2] = 1;

game_body[game_sign_y[2] - 1][game_sign_x[2] + 1] = 1;

game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_x[0] == game_sign_x[2]&&game_sign_x[0] == game_sign_x[3]&&game_sign_y[1] == game_sign_y[2]&&game_sign_x[0] >= 2) {

if(game_body[game_sign_y[0]][game_sign_x[0] - 2] != 2&&game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] !=

2&&game_body[game_sign_y[3] - 2][game_sign_x[3]] != 2) {

num_csh_game();

game_body[game_sign_y[0]][game_sign_x[0] - 2] = 1;

game_body[game_sign_y[1]][game_sign_x[1]] = 1; game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] = 1;

game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_y[0] == game_sign_y[1]&&game_sign_y[0] == game_sign_y[2]&&game_sign_x[1] == game_sign_x[3]&&game_sign_y[0] <= 16) {

if(game_body[game_sign_y[0] + 2][game_sign_x[0]] != 2&&game_body[game_sign_y[1] + 1][game_sign_x[1] - 1] !=

2&&game_body[game_sign_y[2]][game_sign_x[2] - 2] != 2)

{

num_csh_game();

game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1;

game_body[game_sign_y[1] + 1][game_sign_x[1] - 1] = 1;

game_body[game_sign_y[2]][game_sign_x[2] - 2] = 1;

game_body[game_sign_y[3]][game_sign_x[3]] = 1; infoTex.setText(\"游戏进行中!\"); repaint(); } } }

if(blockNumber == 5&&downSign == false)//变换转弯3有4种情况 {

if(game_sign_x[0] == game_sign_x[2]&&game_sign_x[2] == game_sign_x[3]&&game_sign_y[0] == game_sign_y[1]&&game_sign_x[1] >= 2) {

if(game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] != 2&&game_body[game_sign_y[1]][game_sign_x[1] - 2] !=

2&&game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1] - 2] = 1;

game_body[game_sign_y[2]][game_sign_x[2]] = 1; game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_y[1] == game_sign_y[2]&&game_sign_y[2] == game_sign_y[3]&&game_sign_x[0] == game_sign_x[1]&&game_sign_y[0] <= 16) {

if(game_body[game_sign_y[0] + 2][game_sign_x[0]] != 2&&game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] !=

2&&game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 2][game_sign_x[0]] = 1;

game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1;

game_body[game_sign_y[2]][game_sign_x[2]] = 1; game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_x[0] == game_sign_x[1]&&game_sign_x[1] ==

game_sign_x[3]&&game_sign_y[2] == game_sign_y[3]) {

if(game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] != 2&&game_body[game_sign_y[2]][game_sign_x[2] + 2] !=

2&&game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1]] = 1;

game_body[game_sign_y[2]][game_sign_x[2] + 2] = 1;

game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_y[0] == game_sign_y[1]&&game_sign_y[1] == game_sign_y[2]&&game_sign_x[2] == game_sign_x[3]) {

if(game_body[game_sign_y[0] + 1][game_sign_x[0] + 1] != 2&&game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] !=

2&&game_body[game_sign_y[3] - 2][game_sign_x[3]] != 2)

{

num_csh_game();

game_body[game_sign_y[0] + 1][game_sign_x[0] + 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1]] = 1; game_body[game_sign_y[2] - 1][game_sign_x[2] - 1] = 1;

game_body[game_sign_y[3] - 2][game_sign_x[3]] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } } }

if(blockNumber == 6&&downSign == false)//变换两层砖块1的2种情况 {

if(game_sign_x[0] == game_sign_x[2]&&game_sign_x[0] >= 2) {

if(game_body[game_sign_y[0]][game_sign_x[0] - 2] != 2&&game_body[game_sign_y[2] - 1][game_sign_x[2] -1 ] !=

2&&game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] != 2) {

num_csh_game();

game_body[game_sign_y[0]][game_sign_x[0] - 2] = 1;

game_body[game_sign_y[1]][game_sign_x[1]] = 1; game_body[game_sign_y[2] -

1][game_sign_x[2] - 1] = 1;

game_body[game_sign_y[3] - 1][game_sign_x[3] + 1] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } }

if(game_sign_y[0] == game_sign_y[1]&&game_sign_y[3] <= 17) {

if(game_body[game_sign_y[0]][game_sign_x[0] + 2] != 2&&game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] !=

2&&game_body[game_sign_y[3] + 1][game_sign_x[3] - 1] != 2) {

num_csh_game();

game_body[game_sign_y[0]][game_sign_x[0] + 2] = 1;

game_body[game_sign_y[1] + 1][game_sign_x[1] + 1] = 1;

game_body[game_sign_y[2]][game_sign_x[2]] = 1; game_body[game_sign_y[3] + 1][game_sign_x[3] - 1] = 1;

infoTex.setText(\"游戏进行中!\"); repaint(); } } }

if(blockNumber == 7&&downSign == false)//变换两层砖块2的2种情况 {

if(game_sign_x[0] == game_sign_x[1]&&game_sign_x[0] <= 16) {

if(game_body[game_sign_y[0]][game_sign_x[0] + 2] != 2&&game_body[game_sign_y[1] - 1][game_sign_x[1] + 1] !=

2&&game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] != 2) {

num_csh_game();

game_body[game_sign_y[0]][game_sign_x[0] + 2] = 1;

game_body[game_sign_y[1] - 1][game_sign_x[1] + 1] = 1;

game_body[game_sign_y[2]][game_sign_x[2]] = 1; game_body[game_sign_y[3] - 1][game_sign_x[3] - 1] = 1;

infoTex.setText(\"游戏进行中!\");

repaint(); } }

if(game_sign_y[0] == game_sign_y[1]&&game_sign_y[2] <= 17) {

if(game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] != 2&&game_body[game_sign_y[1]][game_sign_x[1] - 2] !=

2&&game_body[game_sign_y[2] + 1][game_sign_x[2] + 1] != 2) {

num_csh_game();

game_body[game_sign_y[0] + 1][game_sign_x[0] - 1] = 1;

game_body[game_sign_y[1]][game_sign_x[1] - 2] = 1;

game_body[game_sign_y[2] + 1][game_sign_x[2] + 1] = 1;

game_body[game_sign_y[3]][game_sign_x[3]] = 1; infoTex.setText(\"游戏进行中!\"); repaint(); } } } } }

因篇幅问题不能全部显示,请点此查看更多更全内容