完整版俄罗斯方块毕业课程设计报告.docx
- 文档编号:926392
- 上传时间:2022-10-14
- 格式:DOCX
- 页数:30
- 大小:22.67KB
完整版俄罗斯方块毕业课程设计报告.docx
《完整版俄罗斯方块毕业课程设计报告.docx》由会员分享,可在线阅读,更多相关《完整版俄罗斯方块毕业课程设计报告.docx(30页珍藏版)》请在冰豆网上搜索。
完整版俄罗斯方块毕业课程设计报告
一、系统概述
1.1现状分析
在个人电脑日益普及的今天,一些有趣的桌面游戏已经成为人们在使用计算机进行工作或学习之余休闲娱乐的首选,而俄罗斯方块游戏是人们最熟悉的小游戏之一,它以其趣味性强,易上手等诸多特点得到了大众的认可,因此开发此游戏软件可满足人们的一些娱乐的需求。
此俄罗斯方块游戏可以为用户提供一个可在普通个人电脑上运行的,界面美观的,易于控制的俄罗斯方块游戏。
1.2项目要求
俄罗斯方块游戏是一款适合大众的游戏软件,它适合不同年龄的人玩。
本软件要实现的功能如下:
(1)游戏区:
玩家可以在游戏区中堆积方块,并能够在游戏过程中随时了解得分情况。
(2)游戏控制:
玩家可以通过游戏控制功能来选择开始新的一局游戏,暂停或退出游戏。
(3)级别设置:
玩家可以根据自己的需要自行设定游戏的开始级别,级别越高,游戏的速度越快,难度越大。
(4)系统功能模块示意图如下:
二、设计说明
2.1游戏区模块
2.2控制区模块
2.3系统流程图
2.4系统操作界面
游戏打开界面
游戏进行中界面
三、源程序编码
importjavax.swing.*;
importjava.awt.*;
importjavax.swing.border.Border;
importjava.awt.event.*;
publicclassErsBlocksGameextendsJFrame{
publicfinalstaticintalinescore=100;
publicfinalstaticinteverylevelscore=alinescore*20;
publicfinalstaticintmaxlevel=10;
publicfinalstaticintinitlevel=5;
privateGameCanvascanvas;
privateErsBlockblock;
privatebooleanplaying=false;
privateControlPanelctrlPanel;
privateJMenuBarbar=newJMenuBar();
privateJMenu
mGame=newJMenu("游戏"),
mControl=newJMenu("控制"),
mhelp=newJMenu("帮助");
privateJMenuItem
miNewGame=newJMenuItem("新游戏"),
milevelup=newJMenuItem("提高级数"),
mileveldown=newJMenuItem("降低级数"),
miExit=newJMenuItem("退出"),
miPlay=newJMenuItem("开始"),
miPause=newJMenuItem("暂停"),
miResume=newJMenuItem("重新开始"),
miStop=newJMenuItem("停止"),
miCtrlBlock=newJMenuItem("方块控制键");
publicErsBlocksGame(Stringtitle)
{
super(title);
setSize(315,392);
DimensionscrSize=Toolkit.getDefaultToolkit().getScreenSize();
setLocation((scrSize.width-getSize().width)/2,
(scrSize.height-getSize().height)/2);
createMenu();
Containercontainer=getContentPane();
container.setLayout(newBorderLayout(6,0));
canvas=newGameCanvas(20,12);
ctrlPanel=newControlPanel(this);
container.add(canvas,BorderLayout.CENTER);
container.add(ctrlPanel,BorderLayout.EAST);
addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEventwe){
stopGame();
System.exit(0);
}
});
addComponentListener(newComponentAdapter(){
publicvoidcomponentResized(ComponentEventce){
canvas.fanning();
}
});
show();
canvas.fanning();
}
privatevoidcreateMenu()
{
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.add(miPause);
mControl.addSeparator();
mControl.add(miResume);
mControl.addSeparator();
mControl.add(miStop);
mhelp.add(miCtrlBlock);
setJMenuBar(bar);
miNewGame.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
stopGame();
reset();
setLevel(initlevel);
}
});
mileveldown.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
intcurLevel=getLevel();
if(curLevel>1)
setLevel(curLevel-1);
}
});
milevelup.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
intcurLevel=getLevel();
if(curLevel>1)
setLevel(curLevel+1);
}
});
miExit.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
System.exit(0);
}
});
miPlay.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
playGame();
}
});
miPause.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
pauseGame();
}
});
miResume.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
resumeGame();
}
});
miStop.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
stopGame();
}
});
miCtrlBlock.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventae)
{
reportGameMethod();
}
});
}
publicvoidreset()
{
ctrlPanel.reset();
canvas.reset();
}
publicbooleanisPlaying()
{
returnplaying;
}
publicErsBlockgetCurBlock()
{
returnblock;
}
publicGameCanvasgetCanvas()
{
returncanvas;
}
publicvoidplayGame()
{
play();
ctrlPanel.setPlayButtonEnable(false);
miPlay.setEnabled(false);
ctrlPanel.requestFocus();
}
publicvoidpauseGame()
{
if(block!
=null)
block.pauseMove();
ctrlPanel.setPauseButtonLabel(false);
miPause.setEnabled(false);
miResume.setEnabled(true);
}
publicvoidresumeGame()
{
if(block!
=null)
block.resumeMove();
ctrlPanel.setPauseButtonLabel(true);
miPause.setEnabled(true);
miResume.setEnabled(false);
ctrlPanel.request
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整版 俄罗斯方块 毕业 课程设计 报告