ImageVerifierCode 换一换
格式:DOCX , 页数:55 ,大小:117.71KB ,
资源ID:7023403      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-7023403.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Java俄罗斯方块单人游戏课程设计Word格式.docx)为本站会员(b****4)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

Java俄罗斯方块单人游戏课程设计Word格式.docx

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

2、) 级别设置:玩家可以根据自己的需要自行设定游戏的开始级别,级别越高,游戏的速度越快,难度越大。1.3系统功能模块示意图 设计说明 1.1游戏区模块1.2控制区模块1.3系统流程图1.4模块简介(1)模块功能简介:模块4-方块颜色、形状、变化此模块主要通过接口、类,来实现俄罗斯方块的颜色、形状(共28种形态)、变化(包括移动与变形)(2)功能模块图: 模块实现代码: class ErsBox implements Cloneable private boolean isColor; private Dimension size = new Dimension(); public ErsBox(

3、boolean isColor) this.isColor = isColor; public boolean isColorBox() return isColor; public void setColor(boolean isColor) public Dimension getSize() return size; public void setSize(Dimension size) this.size = size; public Object clone() Object cloned = null; try cloned = super.clone(); catch (Exce

4、ption ex) ex.printStackTrace(); return cloned;class ErsBlock extends Thread public final static int boxes_rows = 4; public final static int boxes_cols = 4; public final static int flatgene = 3; public final static int betweenleveltime = 50; private final static int blockkindnum = 7; private final st

5、atic int blockstatusnum = 4; public final static int STYLES = / 共28种状态 0x0f00, 0x4444, 0x0f00, 0x4444, / 长条型的四种状态 0x04e0, 0x0464, 0x00e4, 0x04c4, / T型的四种状态 0x4620, 0x6c00, 0x4620, 0x6c00, / 反Z 0x2640, 0xc600, 0x2640, 0xc600, / 0x6220, 0x1700, 0x2230, 0x0740, / 7 0x6440, 0x0e20, 0x44c0, 0x8e00, / 反 0

6、x0660, 0x0660, 0x0660, 0x0660, / 方块的四种状态 ; private GameCanvas canvas; private ErsBox boxes = new ErsBoxboxes_rowsboxes_cols; private int style, y, x, level; private boolean pausing = false, moving = true; public ErsBlock(int style, int y, int x, int level, GameCanvas canvas) this.style = style; this

7、.y = y; this.x = x; this.level = level; this.canvas = canvas; int key = 0x8000; for (int i = 0; i boxes.length; i+) for (int j = 0; j = 1; display(); public void run() while (moving) try sleep(betweenleveltime * (ErsBlocksGame.maxlevel - level + flatgene); catch (InterruptedException ie) ie.printSta

8、ckTrace(); if (!pausing) 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() blockkindnum; blockstatusnum; j+) if (STYLESij = style) int newStyle = STYLESi(j + 1) % bl

9、ockstatusnum; turnTo(newStyle); return; public void pauseMove() pausing = true; public void resumeMove() pausing = false; public void stopMove() moving = false; private void earse() if (boxesij.isColorBox() ErsBox box = canvas.getBox(i + y, j + x); if (box = null) continue; box.setColor(false); priv

10、ate void display() i+) ErsBox box = canvas.getBox(y + i, x + j); if (box = null) box.setColor(true); private boolean isMoveAble(int newRow, int newCol) earse(); if (boxesij.isColorBox() ErsBox box = canvas.getBox(newRow + i, newCol + j); if (box = null | (box.isColorBox() display(); return false; re

11、turn true; private synchronized boolean moveTo(int newRow, int newCol) if (!isMoveAble(newRow, newCol) | !moving) return false; y = newRow; x = newCol; canvas.repaint(); private boolean isTurnAble(int newStyle) if (newStyle &= 0) if (box = null | box.isColorBox() private boolean turnTo(int newStyle)

12、isTurnAble(newStyle) | ! boolean isColor = (newStyle & boxesij.setColor(isColor); style = newStyle;模块实现:颜色: (提示出现时为红色); (出现时为绿色) 形状: 注:每一个方块有四种形态,共计7*4=28种源程序编码import javax.swing.*;import java.awt.*;import javax.swing.border.Border;import java.awt.event.*;public class ErsBlocksGame extends JFrame pu

13、blic final static int alinescore = 100; public final static int everylevelscore = alinescore * 20; public final static int maxlevel = 10; public final static int initlevel = 5;private Game Canvas canvas; private ErsBlock block; private boolean playing = false; private ControlPanel ctrlPanel;private

14、JMenuBar bar = new JMenuBar(); private JMenu mGame = new JMenu(游戏), mControl = new JMenu(控制 mhelp = new JMenu(帮助); private JMenuItem miNewGame = new JMenuItem(新游戏 milevelup = new JMenuItem(提高级数 mileveldown = new JMenuItem(降低级数 miExit = new JMenuItem(退出 miPlay = new JMenuItem(开始 miPause = new JMenuIt

15、em(暂停 miResume = new JMenuItem(重新开始 miStop = new JMenuItem(停止 miCtrlBlock = new JMenuItem(方块控制键 public ErsBlocksGame(String title) super(title); setSize(315, 392); Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(scrSize.width - getSize().width) / 2, (scrSize.height - get

16、Size().height) / 2);createMenu();Container container = getContentPane(); container.setLayout(new BorderLayout(6, 0);canvas = new GameCanvas(20, 12); ctrlPanel = new ControlPanel(this);container.add(canvas, BorderLayout.CENTER); container.add(ctrlPanel, BorderLayout.EAST); addWindowListener(new Windo

17、wAdapter() public void windowClosing(WindowEvent we) stopGame(); System.exit(0); ); addComponentListener(new ComponentAdapter() public void componentResized(ComponentEvent ce) canvas.fanning(); show(); canvas.fanning(); private void createMenu() bar.add(mGame); bar.add(mControl); bar.add(mhelp);mGam

18、e.add(miNewGame); mGame.addSeparator(); mGame.add(milevelup); mGame.add(mileveldown); mGame.add(miExit);mControl.add(miPlay); mControl.addSeparator(); mControl.add(miPause); mControl.add(miResume); mControl.add(miStop);mhelp.add(miCtrlBlock);setJMenuBar(bar); miNewGame.addActionListener(new ActionLi

19、stener() public void actionPerformed(ActionEvent ae) reset(); setLevel(initlevel); mileveldown.addActionListener(new ActionListener() public void actionPerformed(ActionEvent ae) int curLevel = getLevel(); if (curLevel 1) setLevel(curLevel - 1); milevelup.addActionListener(new ActionListener() setLev

20、el(curLevel+1); miExit.addActionListener(new ActionListener() miPlay.addActionListener(new ActionListener() playGame(); miPause.addActionListener(new ActionListener() pauseGame(); miResume.addActionListener(new ActionListener() resumeGame(); miStop.addActionListener(new ActionListener() miCtrlBlock.addActionListener(new ActionListener() reportGameMethod(); public void reset() ctrlPanel.reset(); canvas.reset(); public boolean isPlaying() return playing; public ErsBlock getCurBlock() return bl

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2