文档介绍:附录4:防空战游戏程序
// Example 11-5: 地空战游戏程序
#include <>
#include ""
// 定义飞机类
class CPlane: public CObject
{
CPoint m_pointPlane; // 飞机位置
CBitmap m_bmpPlane; // 飞机图象
int m_nWidth; // 飞机图象宽
int m_nHeight; // 飞机图象高
public:
CPlane();
void ShowPlane(CDC *pDC, CDC *pMemDC, CRect Client);
CRect GetPlane(){return CRect(, ,
+m_nWidth, +m_nHeight);}
void ChangePos();
void ResetPos(){ = 0;}
};
// 飞机类的成员函数
// 构造函数
CPlane::CPlane()
{
m_pointPlane = CPoint(0, 50);
(IDB_PLANE);
BITMAP BM;
(&BM);
m_nWidth = ;
m_nHeight = ;
}
// 显示飞机
void CPlane::ShowPlane(CDC *pDC, CDC *pMemDC, CRect Client)
{
pMemDC->SelectObject(&m_bmpPlane);
pDC->BitBlt(, ,
m_nWidth, m_nHeight, pMemDC,0,0,SRCAND);
}
// 改变飞机位置
void CPlane::ChangePos()
{
if(>788)
= 0;
else
+= 10;
}
// 定义炸弹类
class CBomb: public CObject
{
CPoint m_pointBomb; // 炸弹位置
CBitmap m_bmpBomb; // 炸弹图象
int m_nWidth; // 炸弹图象高
int m_nHeight; // 炸弹图象宽
public:
CBomb();
void ShowBomb(CDC *pDC, CDC *pMemDC, CRect Client);
CRect GetBomb(){return CRect(, ,
+m_nWidth, +m_nHeight);}
void ChangePos(int x);
void Re