附录4:防空战游戏程序 368 m pointMoutain[o]= CPoint(300, 400) m pointMoutain[1]= CPoint(400, 300 m pointMoutain[2]= CPoint(500, 350) m pointMoutain[3]= CPoint (600, 250) m pointMoutain[4]=CPoint(800, 400) /更新窗口客户区 void CMyWnd:: OnPaint o CPaintDC dc(this) CDC MemO MemDC. Create CompatibleDC (NULL) GetClient Rect(&rect) DrawFields(&dc, rect) //画战场 m_ Plane. ShowPlan(&dc,& MemO,rect);//画对方飞机 m Bomb. ShowBomb(&dc //画炸弹 m Tank. Show Tank(&dc rec //画己方防空导弹车 m Stone. ShowStone(&dc DC,rect);//画导弹 /响应菜单消息:开始游戏 void CMy Wnd:: OnBeginO m Bomb. ResetPoso m Plane. ResetPos o m Stone. ResetPos o Invalidate SetTimer(1, 100, NULL) //响应菜单消息:游戏结束 void CMyWnd:: OnEnd O KillTimer(1) PostMessage(WM QUIT) //定时器消息响应函数 void CMy Wnd: OnTimer (UINT nIDEvent附录 4:防空战游戏程序 - 368 - m_pointMoutain[0] = CPoint(300, 400); m_pointMoutain[1] = CPoint(400, 300); m_pointMoutain[2] = CPoint(500, 350); m_pointMoutain[3] = CPoint(600, 250); m_pointMoutain[4] = CPoint(800, 400); } // 更新窗口客户区 void CMyWnd::OnPaint() { CPaintDC dc(this); CDC MemDC; MemDC.CreateCompatibleDC(NULL); CRect rect; GetClientRect(&rect); DrawFields(&dc, rect); // 画战场 m_Plane.ShowPlane(&dc, &MemDC, rect); // 画对方飞机 m_Bomb.ShowBomb(&dc, &MemDC, rect); // 画炸弹 m_Tank.ShowTank(&dc, &MemDC, rect); // 画己方防空导弹车 m_Stone.ShowStone(&dc, &MemDC, rect); // 画导弹 } // 响应菜单消息: 开始游戏 void CMyWnd::OnBegin() { m_Bomb.ResetPos(); m_Plane.ResetPos(); m_Tank.ResetPos(); m_Stone.ResetPos(); Invalidate(); SetTimer(1, 100, NULL); } // 响应菜单消息: 游戏结束 void CMyWnd::OnEnd() { KillTimer(1); PostMessage(WM_QUIT); } // 定时器消息响应函数 void CMyWnd::OnTimer(UINT nIDEvent)