java俄罗斯方块代码_java俄罗斯方块代码.doc

本文档提供了使用Java编写的俄罗斯方块游戏代码,包括GameWin类、right类等,实现了游戏窗口设置、键盘监听、游戏逻辑等功能。通过调试,代码在JDK1.6环境下运行正常。
摘要由CSDN通过智能技术生成

《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。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值