//不多说,直接可以拷贝下面的东西,就可以运行。
package day04; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.applet.*; import java.lang.String.*; import java.lang.*; import java.io.*;
public class ERSBlock extends JPanel implements ActionListener,KeyListener//应该是继承JPanel {
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(\); static Label infoTex = new Label(\); static Label speedTex = new Label(\);
static JFrame jf = new JFrame(); static MyTimer timer; static
ImageIcon
icon=new
ImageIcon(\); static JMenuBar mb = new JMenuBar(); static JMenu menu0 = new JMenu(\游戏 \); static JMenu menu1 = new JMenu(\帮助 \);
static JMenuItem mi0 = new JMenuItem(\新 游 戏\); static JMenuItem mi1 = new JMenuItem(\退出\); static JMenuItem mi1_0 = new JMenuItem(\关于\); static JDialog dlg_1;
static JTextArea dlg_1_text = new JTextArea(); 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;
public static void main(String args[]) {
ERSBlock myBlock = new ERSBlock();
mb.add(menu0); mb.add(menu1); menu0.add(mi0); menu0.add(mi1); menu1.add(mi1_0);
jf.setJMenuBar(mb);
myBlock.init(); jf.add(myBlock); jf.setSize(565,501);
jf.setResizable(false); jf.setTitle(\俄罗斯方块\); jf.setIconImage(icon.getImage()); jf.setLocation(200,100);