预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共20页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

不多说,,直接可以拷贝下面的东西,然后记得把那个BLOCK的名字改成你自己的类名,这个很关键哦,不然是错的可别怪我,呵呵~~ importjava.awt.*; importjava.awt.event.*; importjavax.swing.*; importjava.applet.*; import.*; importjava.lang.*; importjava.io.*; publicclassBlockextendsJPanelimplementsActionListener,KeyListener//应该是继承JPanel { staticButtonbut[]=newButton[6]; staticButtonnoStop=newButton("取消暂停"); staticLabelscoreLab=newLabel("分数:"); staticLabelinfoLab=newLabel("提示:"); staticLabelspeedLab=newLabel("级数:"); staticLabelscoreTex=newLabel("0"); staticLabelinfoTex=newLabel(""); staticLabelspeedTex=newLabel("1"); staticJFramejf=newJFrame(); staticMyTimertimer; staticImageIconicon=newImageIcon("resource/Block.jpg"); staticJMenuBarmb=newJMenuBar(); staticJMenumenu0=newJMenu("游戏"); staticJMenumenu1=newJMenu("帮助"); staticJMenuItemmi0=newJMenuItem("新游戏"); staticJMenuItemmi1=newJMenuItem("退出"); staticJMenuItemmi1_0=newJMenuItem("关于"); staticJDialogdlg_1; staticJTextAreadlg_1_text=newJTextArea(); staticintstartSign=0;//游戏开始标志0未开始1开始2暂停 staticStringbutLab[]={"开始游戏","重新开始","降低级数","提高级数","游戏暂停","退出游戏"}; staticintgame_body[][]=newint[19][10]; staticintgame_sign_x[]=newint[4];//用于记录4个方格的水平位置 staticintgame_sign_y[]=newint[4];//用于记录4个方格的垂直位置 staticbooleandownSign=false;//是否落下 staticintblockNumber=1;//砖块的编号 staticintgameScore=0;//游戏分数 staticintspeedMark=1; publicstaticvoidmain(Stringargs[]) { BlockmyBlock=newBlock(); 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); jf.show(); timer=newMyTimer(myBlock);//启动线程 timer.setDaemon(true); timer.start(); timer.suspend(); } publicvoidinit() { setLayout(null); for(inti=0;i<6;i++) { but[i]=newButton(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(info