//大爱伙可以先把源码copy到机器上试一下,再回贴,这是我上学时写的一直没有公开过(不过还有些bug代码也没重构,后来//没时间放下了 一直没写下去了,不怎么会玩贴多次发送吧),分不多谢谢大家的支持谢谢大家无声的掌声^_^
package game;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.Timer;
import javax.swing.border.Border;
public class QuareGame extends JFrame implements ActionListener {
private GamePanel gamePanel ;
//菜单工具组件
JMenuBar menuBar = new JMenuBar();
//menuBar.setSize(20, 20);
JMenu menuFile = new JMenu("游戏");
JMenuItem newGame = new JMenuItem("新游戏");
JMenuItem pauseGame = new JMenuItem("暂停");
JMenuItem overGame = new JMenuItem("结束");
JMenu menuHelp=new JMenu("帮助");
//
JLabel labLevel=new JLabel("选择关卡:");
JTextField txtLevel=new JTextField();
public QuareGame(GamePanel gp) {
setBounds(500, 100, 400, 480);
setTitle("my small game");
setLayout(new BorderLayout());
JFrame.setDefaultLookAndFeelDecorated(true);
//添加菜单条
setJMenuBar(createMenuBar());
this.gamePanel = gp;
if(gamePanel!=null){
add(gamePanel);
addKeyListener(gamePanel);
}
labLevel.setBounds(260, 140, 50, 30);
txtLevel.setBounds(260, 180, 50, 30);
// add(labLevel);
// add(txtLevel);
setVisible(true);
// setResizable(false);
}
// 菜单条
public JMenuBar createMenuBar() {
menuFile.add(newGame);
menuFile.add(pauseGame);
menuFile.add(overGame);
menuBar.add(menuFile);
menuBar.add(menuHelp);
menuHelp.add(new JMenuItem("版本号"));
//添加事件
newGame.addActionListener(this);
pauseGame.addActionListener(this);
overGame.addActionListener(this);
return menuBar;
}
public static void main(String[] args) {
JFrame.setDefaultLookAndFeelDecorated(true);
QuareGame game = new QuareGame(new GamePanel(new int[22][12] ,new int[2][2]));
}
@Override
public void actionPerformed(ActionEvent e) {
//System.out.println(e.getActionCommand());
if(e.getActionCommand(). equals("新游戏")){
System.out.println("newgame");
if(gamePanel!=null){
remove(gamePanel);
removeKeyListener(gamePanel);
}
this.gamePanel = new GamePanel(new int[22][12] ,new int[2][2]);
add(gamePanel);
addKeyListener(gamePanel);
}else if(e.getActionCommand().equals("暂停")){
pauseGame.setText("继续");
gamePanel.timer.stop();
}else if(e.getActionCommand().equals("继续")){
pauseGame.setText("暂停");
gamePanel.timer.start();
}else if(e.getActionCommand().equals("结束")){
详细解决方案
小弟我们爱分享-俄罗斯方块源码(一分钟copy到机器下试玩上)
热度:9762 发布时间:2013-02-25 21:40:38.0
相关解决方案
- svn版本有关问题svn:this client is too old to work with working copy.
- Runtime.getRuntime().exec("cmd copy G:\\a\\ C:\\goods\\");没有作用解决办法
- 老掉牙的System.arraycopy()有什么地方不如Array.copy
- Copy as active picture 怎么实现应用程序和Word交互
- 发布dll,访问提示异常The located assembly's manifest definition with name 'Copy of TCL" does not match the assembly reference
- 用File.Copy()不能访问路径的有关问题
- 关于 COPY FILE 下令
- 十豆三老师。COPY TO 中路径的有关问题
- copy to 一个临时表解决思路
- 用这种方法 COPY TO aa.XLS TYPE XL5 导出的excel文件,身份证号在excel中双击一下,就会变成科学计数法? 这种方法导出excel,该如何解决
- 关于 COPY FILE 命令,该怎么解决
- [Windows XP] Cannot copy . Access is denied
- copy flash usbflash0 不下去,为何
- 【2010.11.08】SVN版本有关问题:This client is too old to work with working copy
- SVN系列 - svn is not a working copy directory 的解决办法
- bug:svn- Working copy not locked; this
- SVN有关问题:This client is too old to work with working copy
- 解决working copy locked有关问题
- copy 函数不支持中文?解决方法
- java腾挪/复制文件 copy/move file
- weblogic调度报could not copy all resources
- 自各儿写的,利用as3 实现 copy 功能
- 最近接触了一个框架叫Seasar,里面有个方法叫Beans.copy(.),可以把一个对象中的属性值赋给到另一个对象中字段名相同的属性解决思路
- 小弟我把struts 1.2 的包加到了 小弟我的lib报中 copy 了别处的tld文件web。xml strut_config.xml
- eclipse公布应用时Could not copy all resources to tomcat
- eclipse中 “Copy" did not complete normally.异常的真正原因
- path is not a working copy 是什么意思?该怎么解决
- copy .java文件到eclipse 出现中文乱码,怎么解决
- 帮忙调个程序,俄罗斯方块,希望它能一直往上落,跪求
- 求教`java中,怎么实现 List<String> Copy