附录4:防空战游戏程序 /显示炸弹 void CBomb: Show Bomb(CDC *pDC, CDC *pMemDC, CRect Client) pDC->BitBlt(m pointBomb. x, m pointBomb y, m nWidth, m nHeight, pMemDC, 0, 0, SRCAND); /改变位置 void COmb: ChangePos(int x) m pointBomby if(m pointBomb. y)480) m pointBomb.y m pointBomb x //定义高炮类 class CLank: public COb ject CPoint m pointTank;//高炮位置 CBitmap m bmptank: /高炮图象 int m nWidth: /高炮图象宽 int m nHeight //高炮图象高 voidShowTank(CDC *pDC, CDC *pMemDC, CRect Client) CRect Get TankO freturn CRect(m point Tank. x, m pointTank y m pointTank. x+m nWidth, m pointTank. y+m nHeight): 1 void ChangePos (int tag void ResetPosoim pointTank. X=350: I //高炮类成员函数 //高炮类构造函数 Tank:: CRank m pointTank. X= 350 m pointTank. y =450: m bmp Tank. LoadBitmap (IDb TAnk)附录 4:防空战游戏程序 - 364 - // 显示炸弹 void CBomb::ShowBomb(CDC *pDC, CDC *pMemDC, CRect Client) { pMemDC->SelectObject(&m_bmpBomb); pDC->BitBlt(m_pointBomb.x, m_pointBomb.y, m_nWidth, m_nHeight, pMemDC, 0, 0, SRCAND); } // 改变位置 void CBomb::ChangePos(int x) { m_pointBomb.y += 20; if(m_pointBomb.y>480) m_pointBomb.y = 80; m_pointBomb.x = x; } // 定义高炮类 class CTank: public CObject { CPoint m_pointTank;// 高炮位置 CBitmap m_bmpTank; // 高炮图象 int m_nWidth; // 高炮图象宽 int m_nHeight; // 高炮图象高 public: CTank(); voidShowTank(CDC *pDC, CDC *pMemDC, CRect Client); CRect GetTank(){return CRect(m_pointTank.x, m_pointTank.y, m_pointTank.x+m_nWidth, m_pointTank.y+m_nHeight);} voidChangePos(int tag); voidResetPos(){m_pointTank.x = 350;} }; // 高炮类成员函数 // 高炮类构造函数 CTank::CTank() { m_pointTank.x = 350; m_pointTank.y = 450; m_bmpTank.LoadBitmap(IDB_TANK);