不多说,,直接可以拷贝下面的东西,然后记得把那个BLOCK的名字改成你自己的类名,这个很关键哦,不然是错的可别怪我,呵呵~~.*;.*;.*;.*;.*;.*;.*;lassBlockextendsJPanelimplementsActionListener,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/");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();(menu0);(menu1);(mi0);(mi1);(mi1_0);(mb);();(myBlock);(565,501);(false);("俄罗斯方块");(());(200,100);();timer=newMyTimer(myBlock);//(true);();();}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(infoLab);add(infoTex);add(scoreLab);(320,15,30,20);scoreTe
JAVA俄罗斯方块源代码 来自淘豆网m.daumloan.com转载请标明出处.