超级玛丽详细设计文档文档格式.docx
《超级玛丽详细设计文档文档格式.docx》由会员分享,可在线阅读,更多相关《超级玛丽详细设计文档文档格式.docx(16页珍藏版)》请在冰豆网上搜索。
![超级玛丽详细设计文档文档格式.docx](https://file1.bdocx.com/fileroot1/2023-1/24/90f4b37a-f7dc-433d-861d-8aff1465474c/90f4b37a-f7dc-433d-861d-8aff1465474c1.gif)
5)居于多线程,实现进度条
2.2游戏功能划分
游戏的基本功能应该包括菜单处理,程序逻辑处理,持久性处理和挂起恢复处理。
◆关于菜单的处理,包括可以选择的进入游戏、保存、帮助和音效开关等。
◆程序的逻辑处理就是涵盖了程序中除菜单外几乎所有的功能。
◆持久性处理就是资源的载入和游戏的进度保存。
2.3功能划分的架构图
2.4具体的功能模块
1)游戏控制模块
2)查询记录模块
3)关卡选择模块
4)游戏设置模块
2.5功能描述
玩家打开程序,在游戏菜单页面有四个选项。
◆关卡选择:
选择已玩过的关卡进行游戏;
◆开始游戏:
从游戏的第一关进行游戏,玩家通过按键控制主人公马里奥进行不同的操作;
◆查询记录:
查询五个最高游戏分数,排名由上往下递减。
◆游戏设置(包括音乐设置和按键设置):
玩家可以设置游戏进行时的音乐开或关以及修改相应的控制键。
2.6程序的总体架构
本程序采用3层程序架构,业务表现层,业务逻辑层和数据持久层。
◆业务表现层。
主要是游戏界面的绘制,通过指定的接口绘制,与游戏的逻辑分离。
◆业务逻辑层。
主要是游戏的人物和敌人的动作,碰撞的判断,这个与表现层无关,需要表示层调用定义好的接口与逻辑层的通信
◆数据持久层。
保存游戏中的数据,载入游戏中需要的资源,与程序逻辑层无关,用XML文档存储数据
2.7程序的三层结构图
3.面向对象设计
3.1主要类图
3.2各个模块的方法或类名类表示
3.3地图绘制中的坐标说明
4.程序的详细设计
部分源代码如下:
4.1主要人物玛丽的实现
packageorg.liky.mario;
importjava.awt.image.BufferedImage;
publicclassMarioimplementsRunnable{
//坐标
privateintx;
privateinty;
//定义一个场景对象来保存mario当前所处的场景对象
privateBackGroundbg;
//加入线程
privateThreadt=null;
//移动速度
privateintxmove=0;
privateintymove=0;
//状态
privateStringstatus;
//显示的图片
privateBufferedImageshowImage;
//生命数和分数
privateintlife;
privateintscore;
//当前移动中显示的图片数
privateintmoving=0;
privateintupTime=0;
//标记mario是否死亡
privatebooleanisDead=false;
//标记玩家是否完成了全部的游戏
privatebooleanisClear=false;
publicMario(intx,inty){
this.x=x;
this.y=y;
//初始化Mario图片
this.showImage=StaticValue.allMarioImage.get(0);
this.score=0;
this.life=3;
t=newThread(this);
this.status="
right--standing"
;
t.start();
}
publicvoidleftMove(){
//改变速度
this.xmove=-30;
//改变状态
//如果当前已经是跳跃状态,应该保留原有状态,不应该改变状态
if(this.status.indexOf("
jumping"
)!
=-1){
this.status="
left--jumping"
}
else{
left--moving"
publicvoidrightMove(){
this.xmove=30;
right--jumping"
right--moving"
publicvoidleftStop(){
this.xmove=0;
left--standing"
publicvoidrightStop(){
publicvoidjump(){
)==-1){
if(this.status.indexOf("
left"
this.status="
}
else{
ymove=-30;
upTime=6;
publicvoiddown(){
ymove=30;
//mario的死亡方法
publicvoiddead(){
this.life--;
if(this.life==0){
this.showImage=StaticValue.mariodeadImage;
this.isDead=true;
}else{
this.bg.reset();
this.x=0;
this.y=480;
publicintgetX(){
returnx;
publicintgetY(){
returny;
publicvoidsetX(intx){
this.x=x;
publicvoidsetY(inty){
this.y=y;
publicBufferedImagegetShowImage(){
returnshowImage;
publicvoidrun(){
//TODOAuto-generatedmethodstub
while(true){
if(this.bg.isFlag()&
&
this.x>
=508){
//如果为最后一个场景,同时mario的坐标到达了508,则游戏结束
//自动控制游戏结束的移动
this.bg.setOver(true);
if(this.bg.isDown()){
//降旗后,mario开始向城门移动
this.status="
if(this.x<
568){
//mario只向右移动
this.x+=30;
}else{
if(this.y<
480){
//mario向下移动
this.y+=30;
}
if(this.x>
762){
//游戏结束,已经完成了全部的场景
this.isClear=true;
}
}else{
if(this.y<
420){
this.y+=30;
if(this.y>
=420){
this.y=420;
this.status="
}
}else{
//判断当前mario是否与障碍物碰撞
//定义标记
booleancanLeft=true;
booleancanRight=true;
//定义一个mario当前是否处于障碍物上的标记
booleanonLand=false;
for(inti=0;
i<
this.bg.getAllObstruction().size();
i++){
Obstructionob=this.bg.getAllObstruction().get(i);
//如果mario和障碍物相切则不允许mario继续向右移动
if((ob.getX()==this.x+60)
&
(ob.getY()+50>
this.y&
ob.getY()-50<
this.y)){
if(ob.getType()!
=3){
canRight=false;
//不允许mario继续向左移动
if((ob.getX()==this.x-60)
canLeft=false;
//如果符合条件则表明mario当前处在障碍物上面
if(ob.getY()==this.y+60
(ob.getX()+60>
this.x&
ob.getX()-60<
this.x)){
onLand=true;
//判断当前mario在跳跃过程中是否顶到了障碍物
if(upTime>
0){
if(ob.getY()==this.y-60&
(ob.getX()+50>
ob.getX()-50<
//对于砖块处理
if(ob.getType()==0){
//将该砖块从场景中移除
this.bg.getAllObstruction().remove(ob);
//将被移除的砖块保存到一个集合中
this.bg.getRemovedObstruction().add(ob);
//将分数加10
this.score+=10;
}
//对于问号的处理和对于隐藏的砖块的处理
if(ob.getType()==4||ob.getType()==3){
ob.setType
(2);
ob.setImage();
this.score+=50;
upTime=0;
//加入mario对敌人的判断
this.bg.getAllEnemy().size();
Enemye=this.bg.getAllEnemy().get(i);
if((e.getX()+50>
this.x)&
(e.getX()-50<
(e.getY()+60>
e.getY()-60<
//mario死亡
this.dead();
if(e.getY()==this.y+60&
(e.getX()+50>
e.getX()-50<
if(e.getType()==1||e.getType()==3){
e.dead();
this.upTime=2;
this.ymove=-30;
this.score+=50;
}elseif(e.getType()==2){
this.dead();
if(onLand&
upTime==0){
if(xmove==0){
else{
if(xmove==0){
else{
else{
//表示当前为上升状态
if(upTime!
=0){
upTime--;
this.down();
y+=ymove;
if(this.y>
600){
this.dead();
if(canLeft==true&
xmove<
0||(canRight==true&
xmove>
0)){
//改变坐标
x+=xmove;
if(x<
x=0;
//定义一个图片取得的初始索引值
inttemp=0;
//判断mario是否面向左
temp+=5;
//判断mario是否移动
moving"
temp+=this.moving;
moving++;
if(moving==4){
moving=0;
temp+=4;
//改变显示图片
this.showImage=StaticValue.allMarioImage.get(temp);
try{
Thread.sleep(100);
catch(InterruptedExceptione){
e.printStackTrace();
if(this.score==500){
this.life++;
this.score=0;
publicvoidsetBg(BackGroundbg){
this.bg=bg;
publicbooleanisDead(){
returnisDead;
publicintgetLife(){
returnlife;
publicvoidsetLife(intlife){
this.life=life;
publicintgetScore(){
returnscore;
publicvoidsetScore(intscore){
this.score=score;
publicbooleanisClear(){
returnisClear;
}
}