《俄罗斯方块课程设计报告》由会员分享,可在线阅读,更多相关《俄罗斯方块课程设计报告(26页珍藏版)》请在人人文库网上搜索。

1、一、系统概述1.1现状分析在个人电脑日益普及的今天,一些有趣的桌面游戏已经成为人们在使用计算机进行工作或学习之余休闲娱乐的首选,而俄罗斯方块游戏是人们最熟悉的小游戏之一,它以其趣味性强,易上手等诸多特点得到了大众的认可,因此开发此游戏软件可满足人们的一些娱乐的需求。此俄罗斯方块游戏可以为用户提供一个可在普通个人电脑上运行的,界面美观的,易于控制的俄罗斯方块游戏。1.2项目要求俄罗斯方块游戏是一款适合大众的游戏软件,它适合不同年龄的人玩。本软件要实现的功能如下:(1)游戏区:玩家可以在游戏区中堆积方块,并能够在游戏过程中随时了解得分情况。(2)游戏控制:玩家可以通过游戏控制功能来选择开始新的一局。

2、游戏,暂停或退出游戏。(3) 级别设置:玩家可以根据自己的需要自行设定游戏的开始级别,级别越高,游戏的速度越快,难度越大。(4) 系统功能模块示意图如下:俄罗斯方块游戏游戏区游戏控制显示玩家操作显示操作结果开始暂停/继续提高等级退出降低等级二、设计说明2.1游戏区模块游戏区模块创建游戏区处理玩家游戏操作显示游戏结果2.2控制区模块游戏控制模块开始游戏暂停游戏初始级别设置退出游戏2.3系统流程图是否到顶部处理玩家操作开始设置初始级别创建游戏区游戏开局随机选择方块类型是否到顶部方块下落一行游戏结束是否2.4系统操作界面游戏打开界面 游戏进行中界面三、源程序编码import javax.swing.。

3、*;import java.awt.*;import javax.swing.border.Border;import java.awt.event.*;public class ErsBlocksGame extends JFrame public final static int alinescore = 100;public final static int everylevelscore = alinescore * 20;public final static int maxlevel = 10;public final static int initlevel = 5;privat。

4、e GameCanvas canvas;private ErsBlock block;private boolean playing = false;private ControlPanel ctrlPanel;private JMenuBar bar = new JMenuBar();private JMenumGame = new JMenu(游戏),mControl = new JMenu(控制),mhelp = new JMenu(帮助);private JMenuItemmiNewGame = new JMenuItem(新游戏),milevelup = new JMenuItem(。

5、提高级数),mileveldown = new JMenuItem(降低级数),miExit = new JMenuItem(退出),miPlay = new JMenuItem(开始),miPause = new JMenuItem(暂停),miResume = new JMenuItem(重新开始),miStop = new JMenuItem(停止),miCtrlBlock = new JMenuItem(方块控制键);public ErsBlocksGame(String title)super(title);setSize(315, 392);Dimension scrSize = 。

6、Toolkit.getDefaultToolkit().getScreenSize();setLocation(scrSize.width - getSize().width) / 2,(scrSize.height - getSize().height) / 2);createMenu();Container container = getContentPane();container.setLayout(new BorderLayout(6, 0);canvas = new GameCanvas(20, 12);ctrlPanel = new ControlPanel(this);cont。

7、ainer.add(canvas, BorderLayout.CENTER);container.add(ctrlPanel, BorderLayout.EAST);addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent we) stopGame();System.exit(0););addComponentListener(new ComponentAdapter() public void componentResized(ComponentEvent ce) canvas.fanning();。

8、 );show();canvas.fanning();private void createMenu()bar.add(mGame);bar.add(mControl);bar.add(mhelp);mGame.add(miNewGame);mGame.addSeparator();mGame.add(milevelup);mGame.addSeparator();mGame.add(mileveldown);mGame.addSeparator();mGame.add(miExit);mControl.add(miPlay);mControl.addSeparator();mControl.。

9、add(miPause);mControl.addSeparator();mControl.add(miResume);mControl.addSeparator();mControl.add(miStop);mhelp.add(miCtrlBlock);setJMenuBar(bar);miNewGame.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae) stopGame();reset();setLevel(initlevel););mileveldown.addAction。

10、Listener(new ActionListener() public void actionPerformed(ActionEvent ae)int curLevel = getLevel();if (curLevel 1) setLevel(curLevel - 1););milevelup.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae)int curLevel = getLevel();if (curLevel 1) setLevel(curLevel+1););miE。

11、xit.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae) System.exit(0););miPlay.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae)playGame(););miPause.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae)paus。

12、eGame(););miResume.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae)resumeGame(););miStop.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae)stopGame(););miCtrlBlock.addActionListener(new ActionListener() public void actionPerformed(Act。

13、ionEvent ae) reportGameMethod(););public void reset() ctrlPanel.reset(); canvas.reset(); public boolean isPlaying() return playing;public ErsBlock getCurBlock()return block;public GameCanvas getCanvas()return canvas;public void playGame()play();ctrlPanel.setPlayButtonEnable(false);miPlay.setEnabled(。

14、false);ctrlPanel.requestFocus();public void pauseGame() if (block != null) block.pauseMove();ctrlPanel.setPauseButtonLabel(false);miPause.setEnabled(false);miResume.setEnabled(true);public void resumeGame() if (block != null)block.resumeMove();ctrlPanel.setPauseButtonLabel(true);miPause.setEnabled(t。

15、rue);miResume.setEnabled(false);ctrlPanel.requestFocus();public void stopGame()playing = false;if (block != null)block.stopMove();miPlay.setEnabled(true);miPause.setEnabled(true);miResume.setEnabled(false);ctrlPanel.setPlayButtonEnable(true);ctrlPanel.setPauseButtonLabel(true);public int getLevel() 。

16、return ctrlPanel.getLevel();public void setLevel(int level)if (level 0) ctrlPanel.setLevel(level);public int getScore() if (canvas != null)return canvas.getScore();return 0;public int getScoreForLevelUpdate()if (canvas != null) return canvas.getScoreForLevelUpdate();return 0;public boolean levelUpda。

17、te()int curLevel = getLevel();if (curLevel 1)tfLevel.setText( + (level - 1); catch (NumberFormatException e) requestFocus(););addComponentListener(new ComponentAdapter() public void componentResized(ComponentEvent ce)plShowBeforeBlock.fanning(););timer = new Timer(500, new ActionListener() public vo。

18、id actionPerformed(ActionEvent ae) tfScore.setText( + game.getScore();int scoreForLevelUpdate =game.getScoreForLevelUpdate();if (scoreForLevelUpdate = ErsBlocksGame.everylevelscore& scoreForLevelUpdate 0)game.levelUpdate(););timer.start();public void setShowBeforeStyle(int style)plShowBeforeBlock.se。

19、tStyle(style);public int getLevel() int level = 0;try level = Integer.parseInt(tfLevel.getText(); catch (NumberFormatException e) return level;public void setLevel(int level) if (level 0 & level = 1;public void fanning() boxWidth = getSize().width / ErsBlock.boxes_cols;boxHeight = getSize().height /。

20、 ErsBlock.boxes_rows;isTiled = true;private class ControlKeyListener extends KeyAdapterpublic void keyPressed(KeyEvent ke)if (!game.isPlaying() return;ErsBlock block = game.getCurBlock();switch (ke.getKeyCode()case KeyEvent.VK_DOWN:block.moveDown();break;case KeyEvent.VK_LEFT:block.moveLeft();break;。

21、case KeyEvent.VK_RIGHT:block.moveRight();break;case KeyEvent.VK_UP:block.turnNext();break;default:break;class GameCanvas extends JPanel private Color backColor = Color.gray, frontColor = Color.green;private int rows, cols, score = 0, scoreForLevelUpdate = 0;private ErsBox boxes;private int boxWidth,。

22、 boxHeight;public GameCanvas(int rows, int cols)this.rows = rows;this.cols = cols;boxes = new ErsBoxrowscols;for (int i = 0; i boxes.length - 1| col boxes0.length - 1)return null;return (boxesrowcol);public void fanning()boxWidth = getSize().width / cols;boxHeight = getSize().height / rows;public vo。

23、id paintComponent(Graphics g)super.paintComponent(g);g.setColor(frontColor);for (int i = 0; i 0; i-) for (int j = 0; j = 1;display();public void run()while (moving)try sleep(betweenleveltime* (ErsBlocksGame.maxlevel - level + flatgene); catch (InterruptedException ie)ie.printStackTrace();if (!pausin。

24、g)moving = (moveTo(y + 1, x) & moving);public void moveLeft() moveTo(y, x - 1);public void moveRight()moveTo(y, x + 1);public void moveDown()moveTo(y + 1, x);public void turnNext()for (int i = 0; i blockkindnum; i+) for (int j = 0; j blockstatusnum; j+)if (STYLESij = style)int newStyle = STYLESi(j +。

25、 1) % blockstatusnum;turnTo(newStyle);return;public void pauseMove() pausing = true;public void resumeMove()pausing = false;public void stopMove() moving = false;private void earse() for (int i = 0; i boxes.length; i+) for (int j = 0; j boxesi.length; j+)if (boxesij.isColorBox()ErsBox box = canvas.getBox(i + y, j + x);if (box = null)continue;box.setColor(false);private void display() for (int i = 0; i boxes.length; i+)for (int j = 0; j boxesi.length; j+)if (boxesij.isColorBox()ErsBox box = canvas.getBox(y + i, x + j);if (box = null) continue;box.setColor(true。

java俄罗斯方块设计报告,俄罗斯方块课程设计报告相关推荐

  1. 计算机课程编程设计贪吃蛇游戏设计,c语言课程设计报告--贪吃蛇游戏系统

    c语言课程设计报告--贪吃蛇游戏系统 院 系 计算机科学技术学院 班 级 组 长 学 号 指导教师 2017 年 3 月 2 日 C 语言语言基础课程设计基础课程设计 贪贪贪贪吃吃吃吃蛇蛇蛇蛇游游游游 ...

  2. 火车时刻表C语言报告,终稿火车订票系统的设计与实现课程设计.doc最终版(范文1)...

    <火车订票系统的设计与实现课程设计.doc>由会员分享,可免费在线阅读全文,更多与<(终稿)火车订票系统的设计与实现课程设计.doc(最终版)>相关文档资源请在帮帮文库(www ...

  3. java质数和合数的程序_《java项目实训》课程设计计算器.doc

    <java项目实训>课程设计计算器.doc 课程设计报告课程名称JAVA项目实训课程设计设计名称基于JAVA计算器的设计与实现学生学号学生姓名学生学号学生姓名学生学号学生姓名学生学号学生姓 ...

  4. java万年历课程设计代码,JAVA《万年历系统》课程设计

    JAVA<万年历系统>课程设计 面向对象程序设计面向对象程序设计 课程设计报告课程设计报告 题目题目 万年历系统万年历系统 专业专业 计算机科学与技术计算机科学与技术 班级班级 姓名姓名 ...

  5. java课程设计日历_java课程设计日历记事本赵锐.doc

    java课程设计日历记事本赵锐.doc 2本科生课程设计课程名称JAVA程序设计课程设计题目日历记事本学号201440930252学生姓名赵锐所在专业2014计算机学院所在班级信工2班成绩课程设计时间 ...

  6. java课程设计培训班_Java课程设计

    课程设计--博客作业五子棋(201521123009 张晨晨) •团队课程设计博客链接 •个人负责模块或任务说明 五子棋的绘制 棋盘的绘制 重新开始功能的实现 悔棋功能的实现 •自己的代码提交记录截图 ...

  7. java 课程设计 计算器_JAVA课程设计-计算器(201521123028 李家俊)

    1.团队课程设计博客链接 2.个人负责模板或任务说明 主要负责计算器图形界面 包括操作按钮,菜单项以及输出面板的设计 3.自己的代码提交记录截图 4.自己负责模块或任务详细说明 代码分析: 主类中有如 ...

  8. C语言课程信息管理系统课程设计,c语言课程设计学生信息管理系统.doc

    c语言课程设计学生信息管理系统 课程设计报告 课程名称: 高级语言程序设计课程设计 姓 名: 汤璞君 班级学号: BX1209 121003410937 指导教师: 吉顺如 完成日期: 2013.6. ...

  9. 红外遥控C语言程序设计,光电红外遥控开关设计(光电系统课程设计)【PCB图仿真图单片机C语言分工心得】..doc...

    光电红外遥控开关设计(光电系统课程设计)[PCB图仿真图单片机C语言分工心得]. 本科生课程论文 论文题目光电红外遥控开关设计课程名称光电系统设计学生姓名学号所在学院所在班级指导教师 目 录 摘要3 ...

  10. 计算机组成原理课程设计复杂模型机设计,计算机组成原理课程设计(复杂模型机设计).pdf...

    计算机组成原理课程设计(复杂模型机设计) 一.课程设计的目的与要求 1.1 实验目的 1.掌握时序产生器的组成及工作原理:掌握微程序控制器的组成及工作原理: 2.根据给出的指令系统.微指令格式.微命令 ...

最新文章

  1. Ubuntu16.04安装opencv-3.4.2
  2. 20 个有用的 Go 语言微服务开发框架
  3. rstudio 保存_Rstudio学习笔记
  4. mysql grep 提取错误日志_详解grep获取MySQL错误日志信息的方法
  5. z3 C++学习笔记
  6. 【python毕业设计】Django框架实现学生信息管理系统
  7. nagios+pnp4nagios+nagiosql+nodutils
  8. apktool 在mac下的使用 -反编译安卓apk文件
  9. Python学习记录——函数
  10. Study Struts Commons Validator
  11. 念念不忘,必有回响!6月更文活动的一些总结
  12. VSCode调试Python时终端输出中文乱码解决方法2
  13. 同一局域网下电脑传输文件的方式(超简单!)
  14. 计算机桌面如何分区,展示电脑如何分区
  15. VMware虚拟机安装win10 32位
  16. SAP中成本核算结构及构成组件分析
  17. 在 Vue2 中引入高德地图和三维模型
  18. 黑桃符号java怎么打印出来_java入门基础(四)
  19. 蚩尤战团--管理分布
  20. 谷歌L3到L7扎堆升职,股票refresh多过别人年薪!

热门文章

  1. ETC到底要不要装?大力普及的背后到底有哪些不为人知的秘密?
  2. 西门子s7-1200十字红绿灯编程,比较指令
  3. “第五届医疗卫生CIO班”开学典礼隆重举行
  4. 幸福人生讲座(四):孝道与仁爱是根本
  5. 打包rpm包报错contains an invalid rpath
  6. 火线精英服务器维护要多长时间,火线精英游戏退款过程 绝对实用不取巧
  7. 微软如何使Edge成为PWA的最佳浏览器
  8. win7中文旗舰版改英文版
  9. threejst物体匀速移动
  10. 怎样在EDIUS中做出“老电影”特效