《java俄罗斯方块代码.doc》由会员分享,可在线阅读,更多相关《java俄罗斯方块代码.doc(15页珍藏版)》请在人人文库网上搜索。
1、俄罗斯方块代码JDK1.6调试通过调试结果如下:本程序建两个文件,分别命名为RussionBlockGame和Win;其中Win代码如下:import java.awt.*;import java.awt.event.*;import java.awt.geom.*;import javax.swing.*;public class Win public static void main(String args) GameWin frame=new GameWin();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setV。
2、isible(true);public static boolean isplaying=true;class GameWin extends JFramepublic GameWin()this.setFocusable(true);getContentPane().requestFocus();this.setAlwaysOnTop(true);setTitle(super russionBlock);setBounds(350,90,Default_X,Default_Y);setResizable(false);add(jpy1);jpy1.setDividerLocation(304。
3、);jpy1.setDividerSize(4);addKeyListener(jpy2);Thread t=new Thread(jpy2);t.start();public static final int Default_X=500;public static final int Default_Y=630;private left jpy2=new left();private right jpy3=new right();private JSplitPane jpy1=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,jpy2,jpy3);clas。
4、s right extends JPanel implements ActionListenerpublic right()initialframe();initialListener();public void initialframe()setLayout(null);add(jlArray0);jlArray0.setBounds(30,60,70,30);jlArray0.setFocusable(false);add(jlArray1);jlArray1.setBounds(30,140,70,30);jlArray1.setFocusable(false);add(jcArray0。
5、);jcArray0.setBounds(100,60,70,30);jcArray0.setFocusable(false);add(jcArray1);jcArray1.setBounds(100,140,70,30);jcArray1.setFocusable(false);add(jbArray0);jbArray0.setBounds(50,240,100,35);jbArray0.setFocusable(false);add(jbArray1);jbArray1.setBounds(50,310,100,35);jbArray1.setFocusable(false);add(j。
6、bArray2);jbArray2.setBounds(50,380,100,35);jbArray2.setFocusable(false);add(jbArray3);jbArray3.setBounds(50,450,100,35); jbArray3.setFocusable(false);public void initialListener()for(int i=0;i19)moveback();return false;else if(block_boxi19)moveback();return false;else if(game_spaceblock_boxi0block_b。
7、oxi1=1)moveback();return false;return true;public boolean Ishitbottom()for(int i=0;i19)for(int m=0;mbj)temp1=bi;bi=bj;bj=temp1;for(int n=0;n=0;aa-)for(int bb=0;bb10;bb+)game_spaceaa+1bb=game_spaceaabb;for(int cc=0;cc10;cc+)game_space0cc=0;public boolean IsGameOver()boolean flag=false;for(int i=0;isp。
8、_width;i+)if(game_space0i=1)flag=true;break;return flag;public void sure()for(int i=0;i4;i+)game_spaceblock_boxi0block_boxi1=1;public void notsure()for(int i=0;i4;i+)game_spaceblock_boxi0block_boxi1=0;public boolean judge(int i,int j)if(game_spaceij=1)return true;elsereturn false;written by sick_dog邱瑜丹20123.27。