飞机大战游戏 模块设计报告Word下载.docx
《飞机大战游戏 模块设计报告Word下载.docx》由会员分享,可在线阅读,更多相关《飞机大战游戏 模块设计报告Word下载.docx(12页珍藏版)》请在冰点文库上搜索。
模块名称
功能简述
人工智能
人机对战规则的实现
游戏子系统
应用程序对象
游戏程序的加载、游戏对象的绘制、游戏规则的调用、玩家的键盘事件获取
游戏对象
各个游戏对象的抽象父类
战机对象
战机类
敌机对象
敌机类
导弹对象
导弹类
炸弹对象
炸弹类
爆炸对象
爆炸类
文字对象
文字类
2.2UML活动图
2.3类体系
3.游戏规则子系统
功能描述
人机对战规则规则
接口与属性
voidAI(void);
数据结构
与算法
//随机产生敌机
//检测四个方向键,移动战机
//产生战机导弹、炸弹
//碰撞检测
补充说明
4.3游戏对象子系统
CPlaneGameg_Game;
classCPlaneGame
{
public:
virtualvoidOnDraw(CDC*pDC);
//重写以绘制该视图
protected:
//内存DC
CDC*m_pMemDC;
//设备DC
CClientDC*m_pDC;
//内存位图
CBitmap*m_pMemBitmap;
//初始化游戏
BOOLInitGame();
//结束游戏
voidStopGame();
//刷新游戏的帧画面
voidUpdateFrame(CDC*pMemDC);
voidAI();
//获得键的状态1->
down
intGetKey(intnVirtKey)
{
return(GetKeyState(nVirtKey)&
0x8000)?
1:
0;
}
CMyPlane*m_pMe;
CObListm_ObjList[4];
//用链表来管理游戏对象
};
4.2游戏对象
//游戏对象的父类
classCGameObject:
publicCObject
CGameObject(intx=0,inty=0);
virtual~CGameObject();
//绘制对象
virtualBOOLDraw(CDC*pDC,BOOLbPause)=0;
//获得矩形区域
virtualCRectGetRect()=0;
//获得左上角坐标
CPointGetPoint()
returnm_ptPos;
//加载图像
staticBOOLLoadImage(CImageList&
imgList,UINTbmpID,COLORREFcrMask,intcx,intcy,intnInitial);
//物体的位置
CPointm_ptPos;
4.3战机对象
战机类,战机图像加载、贴图、位置存储
CMyPlane*m_pMe;
classCMyPlane:
publicCGameObject
CMyPlane(void);
~CMyPlane(void);
BOOLDraw(CDC*pDC,BOOLbPause);
staticBOOLLoadImage();
voidSetHorMotion(intnMotion)
m_nHorMotion=nMotion;
intGetHorMotion()const
returnm_nHorMotion;
voidSetVerMotion(intnMotion)
m_nVerMotion=nMotion;
intGetVerMotion()const
returnm_nVerMotion;
CRectGetRect()
returnCRect(m_ptPos,CPoint(m_ptPos.x+PLANE_WIDTH,m_ptPos.y+PLANE_HEIGHT));
//是否可以开火发射导弹
BOOLFired();
staticconstintPLANE_WIDTH=50;
staticconstintPLANE_HEIGHT=60;
private:
staticCImageListm_Images;
intm_nHorMotion;
//飞机水平运行方向0->
静止,1->
右-1->
左
intm_nVerMotion;
//飞机垂直运行方向0->
上-1->
下
intm_nWait;
//发射延时
4.4敌机对象
图像加载、贴图、位置存储
newCEnemy
classCEnemy:
CEnemy(void);
~CEnemy(void);
returnCRect(m_ptPos,CPoint(m_ptPos.x+ENEMY_HEIGHT,m_ptPos.y+ENEMY_HEIGHT));
intGetMontion()const
returnm_nMotion;
//是否可以开火发射子弹
staticconstintENEMY_HEIGHT=35;
intm_nMotion;
//方向1->
向下0->
停止-1->
向上
//图像索引
intm_nImgIndex;
//速度
intm_V;
4.5导弹对象
newCBomb
classCBomb:
publicCGameObject
CBomb(intx,inty);
~CBomb(void);
returnCRect(m_ptPos,CPoint(m_ptPos.x+10,m_ptPos.y+BOMB_HEIGHT));
staticconstintBOMB_HEIGHT=20;
4.6炸弹对象
newCBall;
classCBall:
CBall(intx,inty,intnMontion);
~CBall(void);
returnCRect(m_ptPos,CPoint(m_ptPos.x+BALL_HEIGHT,m_ptPos.y+BALL_HEIGHT));
staticconstintBALL_HEIGHT=8;
4.7爆炸对象
newCExplosion;
classCExplosion:
CExplosion(intx,inty);
~CExplosion(void);
returnCRect(m_ptPos,CPoint(m_ptPos.x+EXPLOSION_WIDTH,m_ptPos.y+EXPLOSION_WIDTH));
//炸弹的图片列表
//图像索引的步进计数
intm_nProcess;
staticconstintEXPLOSION_WIDTH=66;
4.4文字对象
newCText;
classCText:
CText(intx,inty);
~CText(void);
returnCRect(m_ptPos,CPoint(m_ptPos.x,m_ptPos.y));