//大爱伙可以先把源码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\\");没有作用解决办法
- copy file的有关问题,多谢
- 老掉牙的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中更新工程出现如上异常:Working copy not locked; this is probably a bug, please report
- SVN系列 - svn is not a working copy directory 的解决办法
- 在eclipse顶用svn提交项目失败 Path is not a working copy directory
- svn Working copy locked 交付不了也更新不了,lock
- <转>解决svn working copy locked有关问题
- 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
- document.execCommand("Copy"); 为何在非IE内核浏览器中不起作用
- Tomcat支配时报错Could not copy all resources to.
- js中设置带中文参数的URL 解决方法(copy)