本科生毕业论文(设计)基于Java的俄罗斯方块的设计与实现姓名学号专业指导教师2013年5月30日I摘要俄罗斯方块作为一款风靡全球的多样化终端游戏,经久不衰。俄罗斯方块简单的基本游戏规则是旋转、移动,游戏自动随机输出7种形状的方块,经旋转后可形成28种形状,方块堆叠在一起,排列成完整的一行或多行消除得分,积分达到一定程度会自动提升级别。该游戏上手简单、老少皆宜、家喻户晓。本论文在详尽分析传统俄罗斯实现的基本原理、基本规则基础上,更深一步地研究俄罗斯方块的创新模式,在经典模式基础上开发出等级可变的模式,以及进一步开发出颜色可变的模式,如随意改变界面的背景色、前景色等,本文对以上功能给出了实现流程、详尽描述、和部分源代码。论文阐述了该游戏的历史、开发此游戏的意义和环境并根据软件工程的相关知识,进行系统的需求分析、概要设计、详细设计与实现、调试运行进行描述。此设计是在MicrosoftWindowsXP系统下,以Java为开发语言,在MyEclipse开发平台上进行游戏的设计与实现。关键词:游戏;俄罗斯方块;软件工程;MyEclipseIIAbstractTetrisisapopularglobaldiversificationofterminalenduringgame.Simplebasicrulesofthegameisrotating,moving,automaticrandomoutputof7kindsofshapesquaregame.Itforms28kindsofshape,afterrotatingcubestackedtogether,formingcompleteoneormorelinestoeliminatescore.Itslevelautomaticallyriseswiththescore.Thegameiseasyforyoungandold,hasbecomeahouseholdname.ThispapernotonlygivethedetailedanalysisofthetraditionalTetriswhichbasedonthebasicprincipleandsimplerulesbutalsodevelopthecolorvariablemodel,suchasrandomchangethebackgroundcolorandforegroundcolorandsoon.Furthermore,inthispaper,theabovefunctionsaregiventheimplementationprocess,thedetaileddescription,andsomesourcecode.Thepaperexpoundsthehistoryofthegame,developsthemeaningofthegameandtheenvironmentofdesign.Accordingtotherelevantknowledgeofsoftwareengineering,theauthorreportsthedemandanalysis,outlinedesign,detaileddesign,planningandexecutionofthetest.ThisdesignisunderMicrosoftWindowsXPsystem,basedonJavadevelopmentlanguage,theMyEclipsedevelopmentplatformstocarryonthedesignandimplementationofthegame.KeyWords:Game,Tetris,Softwareengineering,MyEclipseIII目录1引言...............................................................................................................................12系统的需求分析.............................................................................................................22.1系统需求.................................................................................................................22.2接口控制.................................................................................................................33系统的概要设计.............................................................................................................43.1软件运行和开发工具.............................................................................................43.2系统功能设计.........................................................................................................43.2.1手工处理业务的基本流程.............................................................................43.2.2基本流程的功能模块.....................................................................................54系统的详细设计与实现.................................................................................................84.1游戏主界面显示模块.............................................................................................84.2画布、方块显示模块.............................................................................................94.2.1背景画布模块设计.......................................................................................104.2.2预览方块模块设计.......................................................................................114.2.3方块移动、旋转设计...................................................................................144.3控制面板模块.......................................................................................................184.3.1菜单栏模块设计...........................................................................................184.3.2控制面板按钮设计.......................................................................................205系统的调试运行...........................................................................................................215.1测试的意义及注意事项.......................................................................................215.2游戏代码、算法的测试.......................................................................................215.3游戏界面菜单选项的功能测试...........................................................................225.4按键事件的功能测试...........................................................................................245.5方块堆砌与消行测试...........................................................................................255.6测试结果分析.......................................................................................................266结论...........................................................................................................................27参考文献...........................................................................................................................28致谢.................................................................................................................................2911引言俄罗斯方块的影响已毋庸置疑,当今世界的电脑、手机到处都有俄罗斯方块的踪迹,同时它更是每个游戏平台的必备游戏,相关的复制品不胜枚举。这个最早由莫斯科的数学家亚力克西·帕杰诺夫(AlexeyPajituov)所设计的作品,被公认为有史以来最畅销的经典游戏,至今魅力不减当年。亚力克西·帕杰诺夫曾在俄罗斯科学研究院电脑中心工作,当时他在Eletronica60的旧型俄罗斯主机上进行开发工作,这种机器不支持图形界面,和PC也不兼容。他尝试将一种传统的拼图游戏Pentomino改写成电脑游戏。Pentomino一共有十二种形状,各以七个方块组合而成。帕杰诺夫试着写了一个程序,旋转并移动这十二种不同形状的方块,让它们拼成一大块。后来几经修改,