1、模块名称功能简述人工智能人机对战规则的实现游戏子系统应用程序对象游戏程序的加载、游戏对象的绘制、游戏规则的调用、玩家的键盘事件获取游戏对象各个游戏对象的抽象父类战机对象战机类敌机对象敌机类导弹对象导弹类炸弹对象炸弹类爆炸对象爆炸类文字对象文字类2.2 UML活动图2.3类体系3. 游戏规则子系统 功能描述人机对战规则规则接口与属性void AI( void );数据结构与算法/随机产生敌机/检测四个方向键,移动战机/产生战机导弹、炸弹/碰撞检测补充说明4. 3游戏对象子系统CPlaneGame g_Game;class CPlaneGamepublic: virtual void OnDraw
2、(CDC* pDC); / 重写以绘制该视图protected: /内存DC CDC* m_pMemDC; /设备DC CClientDC* m_pDC; /内存位图 CBitmap* m_pMemBitmap; /初始化游戏 BOOL InitGame(); /结束游戏 void StopGame(); /刷新游戏的帧画面 void UpdateFrame(CDC* pMemDC); void AI(); /获得键的状态1-down int GetKey(int nVirtKey) return (GetKeyState(nVirtKey) & 0x8000)? 1 : 0; CMyPlan
3、e* m_pMe; CObList m_ObjList4; /用链表来管理游戏对象;4.2 游戏对象/游戏对象的父类class CGameObject : public CObject CGameObject(int x=0,int y=0); virtual CGameObject(); /绘制对象 virtual BOOL Draw(CDC* pDC,BOOL bPause)=0; /获得矩形区域 virtual CRect GetRect()=0; /获得左上角坐标 CPoint GetPoint() return m_ptPos; /加载图像 static BOOL LoadImage
4、(CImageList& imgList,UINT bmpID,COLORREF crMask,int cx,int cy,int nInitial); /物体的位置 CPoint m_ptPos;4.3 战机对象战机类,战机图像加载、贴图、位置存储CMyPlane* m_pMe;class CMyPlane :public CGameObject CMyPlane(void); CMyPlane(void); BOOL Draw(CDC* pDC,BOOL bPause); static BOOL LoadImage(); void SetHorMotion(int nMotion) m_n
5、HorMotion = nMotion; int GetHorMotion() const return m_nHorMotion; void SetVerMotion(int nMotion) m_nVerMotion = nMotion; int GetVerMotion() const return m_nVerMotion; CRect GetRect() return CRect(m_ptPos,CPoint(m_ptPos.x+PLANE_WIDTH,m_ptPos.y+PLANE_HEIGHT); /是否可以开火发射导弹 BOOL Fired(); static const in
6、t PLANE_WIDTH=50; static const int PLANE_HEIGHT=60;private: static CImageList m_Images; int m_nHorMotion;/飞机水平运行方向0-静止,1-右 -1-左 int m_nVerMotion;/飞机垂直运行方向0-上 -1-下 int m_nWait;/发射延时4.4 敌机对象图像加载、贴图、位置存储new CEnemyclass CEnemy : CEnemy(void); CEnemy(void); return CRect(m_ptPos,CPoint(m_ptPos.x+ENEMY_HEI
7、GHT,m_ptPos.y+ENEMY_HEIGHT); int GetMontion() const return m_nMotion; /是否可以开火发射子弹 static const int ENEMY_HEIGHT = 35; int m_nMotion;/方向 1-向下 0-停止 -1-向上 /图像索引 int m_nImgIndex; /速度 int m_V;4.5 导弹对象new CBombclass CBomb : public CGameObject CBomb(int x,int y); CBomb(void); return CRect(m_ptPos,CPoint(m_
8、ptPos.x+10,m_ptPos.y+BOMB_HEIGHT); static const int BOMB_HEIGHT = 20;4.6 炸弹对象new CBall;class CBall : CBall(int x,int y,int nMontion); CBall(void); return CRect(m_ptPos,CPoint(m_ptPos.x+BALL_HEIGHT,m_ptPos.y+BALL_HEIGHT); static const int BALL_HEIGHT=8;4.7 爆炸对象new CExplosion;class CExplosion : CExplo
9、sion(int x,int y); CExplosion(void); return CRect(m_ptPos,CPoint(m_ptPos.x+EXPLOSION_WIDTH,m_ptPos.y+EXPLOSION_WIDTH); /炸弹的图片列表 /图像索引的步进计数 int m_nProcess; static const int EXPLOSION_WIDTH = 66;4.4 文字对象new CText;class CText : CText(int x,int y); CText(void); return CRect(m_ptPos,CPoint(m_ptPos.x,m_ptPos.y);
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2