附录4:防空战游戏程序 362 附录4:防空战游戏程序 ∥/ Example11-5:地空战游戏程序 #include <afxwin h #include resource. h //定义飞机类 class CPlane: public COb ject CPoint m pointPlane;//飞机位置 CBitmap m bmpPlane /飞机图象 m nWidth //飞机图象宽 int nHeight //飞机图象高 CPlane o voidShowPlane(CDC *pDC, CDC pMemDC, CRect Client) CRect GetPlaneo freturn CRect(m pointPlane. x, m pointPlaney m nWidth ane y+m nHeight): I void ChangePos o voidResetPosoIm pointPlane x =0: K //飞机类的成员函数 //构造函数 CPlane: CPlane o m pointPlane= CPoint(o, 50 m bmpPlane. LoadBitmap(IDb plane BITMAP BM m bmpPlane. GetBitmap( &BM) m nWidth BM. bmWidth /显示飞机 void CPlane:: ShowPlane(CDC *pDC, CDC *pMemDC, CRect Client) pMemDC->SelectObject(&m bmpPlane) pDC->BitBlt(m pointPlane. x, m pointPlane y,附录 4:防空战游戏程序 - 362 - 附录 4:防空战游戏程序 // Example 11-5: 地空战游戏程序 #include <afxwin.h> #include "resource.h" // 定义飞机类 class CPlane: public CObject { CPoint m_pointPlane; // 飞机位置 CBitmap m_bmpPlane; // 飞机图象 int m_nWidth; // 飞机图象宽 int m_nHeight; // 飞机图象高 public: CPlane(); voidShowPlane(CDC *pDC, CDC *pMemDC, CRect Client); CRect GetPlane(){return CRect(m_pointPlane.x, m_pointPlane.y, m_pointPlane.x+m_nWidth, m_pointPlane.y+m_nHeight);} voidChangePos(); voidResetPos(){m_pointPlane.x = 0;} }; // 飞机类的成员函数 // 构造函数 CPlane::CPlane() { m_pointPlane= CPoint(0, 50); m_bmpPlane.LoadBitmap(IDB_PLANE); BITMAP BM; m_bmpPlane.GetBitmap(&BM); m_nWidth = BM.bmWidth; m_nHeight = BM.bmHeight; } // 显示飞机 void CPlane::ShowPlane(CDC *pDC, CDC *pMemDC, CRect Client) { pMemDC->SelectObject(&m_bmpPlane); pDC->BitBlt(m_pointPlane.x, m_pointPlane.y