版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
概述項目:飛機大戰(zhàn)主要功能有以下幾點:關(guān)卡設(shè)置本次飛機大戰(zhàn)游戲中共設(shè)置了四個關(guān)卡,第一關(guān)的難度設(shè)置較低,僅有敵機對其進行攻擊;第二關(guān)在原有的基礎(chǔ)上增加一些補血的小道具,當(dāng)積分達到一定的時候便會出現(xiàn)該道具,并且敵機出現(xiàn)的頻率也比第一關(guān)高;第三關(guān)在第二關(guān)的基礎(chǔ)上新出現(xiàn)了小boss,并增加了其他的道具;第四關(guān)在第三關(guān)的基礎(chǔ)上再新出現(xiàn)大boss,當(dāng)積分達到要求以及大boss被消滅后通關(guān)成功。敵機設(shè)置小敵機隨機出現(xiàn),炮彈也隨機發(fā)射,當(dāng)小敵機與戰(zhàn)機相撞或被戰(zhàn)機的子彈擊中時,小敵機消失。當(dāng)達到一定積分時,小boss出現(xiàn)并隨機發(fā)射出與小敵機一樣的炮彈,但是炮彈分三個方向發(fā)射出。當(dāng)小boss被戰(zhàn)機的子彈擊中或與戰(zhàn)機相撞時失去5滴血。當(dāng)?shù)竭_四關(guān)并且積分足夠多時出現(xiàn)大boss,同小boss一樣,當(dāng)大boss與戰(zhàn)機相撞或被戰(zhàn)機子彈擊中時失去1滴血。除此之外,小boss和大boss上方都有血條顯示,當(dāng)血條消失時意味著生命消失,大boss和小boss消失。小boss會在屏幕上隨機出現(xiàn)和走動出了屏幕后會在屏幕的任意地方再隨機出現(xiàn),直至血量為0消失。大boss則在屏幕中隨機走動不出屏幕,直至血量為0消失。戰(zhàn)機設(shè)置戰(zhàn)機初始有五條生命,每條命的血量為50,所獲得的積分以及其生命值、血條都在窗口的左上角顯示。在第一、二關(guān)時,按空格鍵戰(zhàn)機會出現(xiàn)兩個向上發(fā)射的炮彈,到第三、四關(guān)的時候,按空格鍵戰(zhàn)機會發(fā)射三個不同方向的炮彈。戰(zhàn)機吃到藥瓶道具時血量會增加20,但不可以超過50;吃到閃電道具時,便可放大招,放大招的次數(shù)為15。當(dāng)戰(zhàn)機被敵方的炮彈擊中或與敵方相撞時,血量減少,減少為0時生命值減1,直至生命值為0。游戲設(shè)置進入游戲時,會有背景音樂,窗口左上角顯示戰(zhàn)機所得積分及其生命值。根據(jù)積分情況進入不同的關(guān)卡。游戲通關(guān)時屏幕清空,并顯示通關(guān)成功,按Y可重新開始游戲。當(dāng)戰(zhàn)機的血量以及生命值為0時,游戲失敗,屏幕清空并顯示游戲結(jié)束,按Y即可重新開始游戲。相關(guān)技術(shù)Windows定時器技術(shù)Windows定時器是一種輸入設(shè)備,它周期性地在每經(jīng)過一個指定的時間間隔后就通知應(yīng)用程序一次。程序?qū)r間間隔告訴windows,然后windows給你的程序發(fā)送周期性發(fā)生的WM_YIMER消息以表示時間到了。本程序在OnCreate()函數(shù)中使用了編號為1的定時器,控制了每30毫秒刷新一次。雙緩沖技術(shù)在內(nèi)存中創(chuàng)建一個與屏幕繪圖區(qū)域一致的對象,先將圖形繪制到內(nèi)存這個對象上,再一次性將這個對象上的圖形拷貝到屏幕上,這樣即可解決圖片閃爍問題。本程序在繪制滾動背景以及飛機,敵機等中用到了該技術(shù)。獲取矩形區(qū)域用CRect定義一個對象,利用這個對象得到要用到的矩形區(qū)域,用IntersectRect函數(shù)來判斷兩個源矩形是不是有重合的部分??傮w設(shè)計與詳細(xì)設(shè)計系統(tǒng)模塊劃分飛機大戰(zhàn)游戲主要模塊可以說是有幾個重要的類組成的。首先是老師給出的CGameObject類,以及在其派生下的Bomb,Ball,Enemy,MyPlane,Explosion,AddBlood等等此處不一一列舉。另外還有CObject派生的BackGround類。如下圖:3.23.2主要功能模塊主要功能是在飛機大戰(zhàn)View類中,OnTimer函數(shù)中實現(xiàn),將各個類調(diào)用,隨機產(chǎn)生敵機,子彈的輸出,爆炸的實現(xiàn)等等。它的實現(xiàn)圖可以如下實現(xiàn):啟動程序游戲初始化初始化游戲?qū)ο蟪跏蓟L圖環(huán)境繪制游戲?qū)ο笈鲎策\算積分判斷游戲是否結(jié)束本程序所包含的功能和類模塊:游戲子系統(tǒng)模塊名稱功能簡述應(yīng)用程序?qū)ο笥螒虺绦虻募虞d、游戲?qū)ο蟮睦L制、玩家的鍵盤事件獲取游戲?qū)ο蟾鱾€游戲?qū)ο蟮某橄蟾割悾–GameObject)戰(zhàn)機對象戰(zhàn)機類(MyPlane)敵機對象敵機類(Enemy,LittleBoss,Boss)導(dǎo)彈對象導(dǎo)彈對象導(dǎo)彈類(Bomb,Bomb2)炸彈對象炸彈類(Ball,BossBall)爆炸對象爆炸類(Explosion)道具對象道具類(AddBlood,AddBomb)編碼實現(xiàn)初始準(zhǔn)備模塊名稱模塊名稱應(yīng)用程序?qū)ο蠊δ苊枋鲇螒虺绦虻募虞d、游戲?qū)ο蟮睦L制、玩家的鍵盤事件獲取數(shù)據(jù)結(jié)構(gòu)與算法CflyfightView::CflyfightView(){//TODO:在此處添加構(gòu)造代碼flag=0;flag2=0;level=1;bossblood=100;}CflyfightView::~CflyfightView(){}BOOLCflyfightView::PreCreateWindow(CREATESTRUCT&cs){//TODO:在此處通過修改//CREATESTRUCTcs來修改窗口類或樣式returnCView::PreCreateWindow(cs);}//CflyfightView繪制voidCflyfightView::OnDraw(CDC*pDC){CflyfightDoc*pDoc=GetDocument();ASSERT_VALID(pDoc);if(!pDoc)return;//TODO:在此處為本機數(shù)據(jù)添加代碼}//CflyfightView打印BOOLCflyfightView::OnPreparePrinting(CPrintInfo*pInfo){//默認(rèn)準(zhǔn)備returnDoPreparePrinting(pInfo);}voidCflyfightView::OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/){{//TODO:添加額外的打印前進行的初始化過程}voidCflyfightView::OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/){//TODO:添加打印后進行的清理過程}//CflyfightView診斷#ifdef_DEBUGvoidCflyfightView::AssertValid()const{CView::AssertValid();}voidCflyfightView::Dump(CDumpContext&dc)const{CView::Dump(dc);}CflyfightDoc*CflyfightView::GetDocument()const//非調(diào)試版本是內(nèi)聯(lián)的{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CflyfightDoc)));return(CflyfightDoc*)m_pDocument;}#endif//_DEBUG//CflyfightView消息處理程序intCflyfightView::OnCreate(LPCREATESTRUCTlpCreateStruct){if(CView::OnCreate(lpCreateStruct)==-1)return-1;//TODO:在此添加專用代碼和/或調(diào)用基類PlaySound((LPCTSTR)IDR_WAVE1,AfxGetInstanceHandle(),SND_RESOURCE|SND_ASYNC|SND_LOOP);SetTimer(1,30,0);CMyPlane::LoadImage();CEnemy::LoadImage();CExplosion::LoadImage();CBomb::LoadImage();CBall::LoadImage();CAddBlood::LoadImage();CAddBomb::LoadImage();CBomb2::LoadImage();CLittleBoss::LoadImage();CBoss::LoadImage();CBossBall::LoadImage();CBossBall::LoadImage();return0;}voidCflyfightView::OnKeyUp(UINTnChar,UINTnRepCnt,UINTnFlags){//TODO:在此添加消息處理程序代碼和/或調(diào)用默認(rèn)值if(nChar==VK_DOWN||VK_UP)myPlane.SetVerMotion(0);if(nChar==VK_RIGHT||VK_LEFT)myPlane.SetHorMotion(0);CView::OnKeyUp(nChar,nRepCnt,nFlags);}戰(zhàn)機對象模塊名稱模塊名稱戰(zhàn)機對象功能描述戰(zhàn)機移動、戰(zhàn)機導(dǎo)彈的發(fā)射數(shù)據(jù)結(jié)構(gòu)與算法shortkey=GetKeyState(VK_RIGHT);shortkey1=GetKeyState(VK_LEFT);shortkey2=GetKeyState(VK_UP);shortkey3=GetKeyState(VK_DOWN);if((key&0x80)!=0)myPlane.SetHorMotion(1);elseif((key1&0x80)!=0)myPlane.SetHorMotion(-1);elseif((key2&0x80)!=0)myPlane.SetVerMotion(-1);elseif((key3&0x80)!=0)myPlane.SetVerMotion(1);voidCflyfightView::OnKeyUp(UINTnChar,UINTnRepCnt,UINTnFlags){//TODO:在此添加消息處理程序代碼和/或調(diào)用默認(rèn)值if(nChar==VK_DOWN||VK_UP)myPlane.SetVerMotion(0);if(nChar==VK_RIGHT||VK_LEFT)myPlane.SetHorMotion(0);CView::OnKeyUp(nChar,nRepCnt,nFlags);}voidCflyfightView::OnKeyDown(UINTnChar,UINTnRepCnt,UINTnFlags){//TODO:在此添加消息處理程序代碼和/或調(diào)用默認(rèn)值if(nChar==VK_SPACE){if(myPlane.Fired())if(flag==0&&(level==1||level==2)){listBomb.AddTail(newCBomb(myPlane.GetPoint().x+10,myPlane.GetPoint().y+20,0,12));listBomb.AddTail(newCBomb(myPlane.GetPoint().x+30,myPlane.GetPoint().y+20,0,12));}elseif(flag==0&&(level==3||level==4)){listBomb.AddTail(newCBomb(myPlane.GetPoint().x+10,myPlane.GetPoint().y+20,5,12));listBomb.AddTail(newCBomb(myPlane.GetPoint().x+30,myPlane.GetPoint().y+20,0,12));listBomb.AddTail(newCBomb(myPlane.GetPoint().x+30,myPlane.GetPoint().y+20,-5,12));}if(flag2!=0){listBomb2.AddTail(newCBomb2(myPlane.GetPoint().x+10,myPlane.GetPoint().y+20,10,10));listBomb2.AddTail(newCBomb2(myPlane.GetPoint().x+40,myPlane.GetPoint().y+20,5,10));listBomb2.AddTail(newCBomb2(myPlane.GetPoint().x+20,myPlane.GetPoint().y+20,0,10));listBomb2.AddTail(newCBomb2(myPlane.GetPoint().x+40,myPlane.GetPoint().y+20,-5,10));listBomb2.AddTail(newCBomb2(myPlane.GetPoint().x+40,myPlane.GetPoint().y+20,-10,10));flag2--;if(flag2<1)flag=0;}}敵機對象模塊名稱模塊名稱敵機對象功能描述敵機、大小boss隨機產(chǎn)生,隨機方向發(fā)射子彈,大boss隨機發(fā)射子彈,大小boss的血條顯示數(shù)據(jù)結(jié)構(gòu)與算法//敵機的隨機產(chǎn)生if(level==1){if(rand()%30==10)listEnemy.AddTail(newCEnemy());}if(level==2||level==3){if(rand()%25==15)listEnemy.AddTail(newCEnemy());}if(level==4)if(rand()%20==15){listEnemy.AddTail(newCEnemy());}//大小Boss的隨機產(chǎn)生if(myPlane.score%600==0&&level!=1&&level!=2)listlboss.AddHead(newCLittleBoss());if(myPlane.score==3630)listboss.AddHead(newCBoss());//敵機、Boss產(chǎn)生子彈posEnemy=listEnemy.GetHeadPosition();while(posEnemy!=NULL){CEnemy*pEnemy=(CEnemy*)listEnemy.GetNext(posEnemy);CPointpoint2=pEnemy->GetPoint();if(rand()%60==1)listBall.AddTail(newCBall(point2.x+10,point2.y+10,0,-12));}poslboss=listlboss.GetHeadPosition();while(poslboss!=NULL){CLittleBoss*plboss=(CLittleBoss*)listlboss.GetNext(poslboss);CPointpoint3=plboss->GetPoint();if(rand()%50==1){listBall.AddTail(newCBall(point3.x+10,point3.y+10,-5,-12));listBall.AddTail(newCBall(point3.x+10,point3.y+10,0,-12));listBall.AddTail(newCBall(point3.x+10,point3.y+10,5,-12));}}posboss=listboss.GetHeadPosition();while(posboss!=NULL){CBoss*pboss=(CBoss*)listboss.GetNext(posboss);CPointpoint4=pboss->GetPoint();if(rand()%40==1){listbossball.AddTail(newCBossBall(point4.x+45,point4.y+90,-5,-12));listbossball.AddTail(newCBossBall(point4.x+45,point4.y+90,0,-12));listbossball.AddTail(newCBossBall(point4.x+45,point4.y+10,5,-12));}}//大Boss血條顯示CBrushbrush;brush.CreateSolidBrush(RGB(255,0,0));pDC->SelectObject(brush);pDC->Rectangle(m_ptPos.x,m_ptPos.y,m_ptPos.x+bblood*0.9,m_ptPos.y-5);//小Boss血條顯示CBrushbrush;brush.CreateSolidBrush(RGB(255,0,0));pDC->SelectObject(brush);pDC->Rectangle(m_ptPos.x,m_ptPos.y,m_ptPos.x+lblood,m_ptPos.y-5);道具對象模塊名稱模塊名稱道具對象功能描述積分達到一定的時候出現(xiàn)道具,戰(zhàn)機吃掉道具,道具消失,戰(zhàn)機補血或獲得技能數(shù)據(jù)結(jié)構(gòu)與算法if(myPlane.score%510==0)listAddblood.AddHead(newCAddBlood());if(myPlane.score%900==0&&level!=1)listaddbomb.AddHead(newCAddBomb());/********加血藥瓶********/POSITIONposaddblood=listAddblood.GetHeadPosition();POSITIONpos4;for(posaddblood;(pos4=posaddblood)!=NULL;){CAddBlood*paddblood=(CAddBlood*)listAddblood.GetNext(posaddblood);paddblood->Draw(&m_mDC,FALSE);CRectrect;intsection=rect.IntersectRect(paddblood->GetRect(),myPlane.GetRect());if(section!=0){if(myPlane.blood<50)myPlane.blood+=20;listAddblood.RemoveAt(pos4);deletepaddblood;break;}}/********技能道具*******/POSITIONposaddbomb=listaddbomb.GetHeadPosition();POSITIONpos5;for(posaddbomb;(pos5=posaddbomb)!=NULL;){CAddBomb*paddbomb=(CAddBomb*)listaddbomb.GetNext(posaddbomb);paddbomb->Draw(&m_mDC,FALSE);CRectrect;intsection=rect.IntersectRect(paddbomb->GetRect(),myPlane.GetRect());if(section!=0){flag=1;flag2=15;listaddbomb.RemoveAt(pos5);deletepaddbomb;break;}}主要內(nèi)容模塊名稱模塊名稱主要內(nèi)容功能描述戰(zhàn)機導(dǎo)彈擊中敵機和大小Boss,戰(zhàn)機與敵機和大小Boss相撞,敵機和大小Boss發(fā)射的炮彈擊中戰(zhàn)機數(shù)據(jù)結(jié)構(gòu)與算法//戰(zhàn)機導(dǎo)彈擊中敵機POSITIONpos1=NULL;//刪除敵機POSITIONpos2=NULL,pos3=NULL;//刪除導(dǎo)彈for(posBomb=listBomb.GetHeadPosition();(pos2=posBomb)!=NULL;){CBomb*pBomb=(CBomb*)listBomb.GetNext(posBomb);for(posEnemy=listEnemy.GetHeadPosition();(pos1=posEnemy)!=NULL;){CRectintersectRect;CEnemy*pEnemy=(CEnemy*)listEnemy.GetNext(posEnemy);intintersectSection=intersectRect.IntersectRect(pEnemy->GetRect(),pBomb->GetRect());if(intersectSection!=0){CRecteRect;eRect=pEnemy->GetRect();listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));myPlane.score+=30;if(myPlane.score%510==0)listAddblood.AddHead(newCAddBlood());if(myPlane.score%900==0&&level!=1)listaddbomb.AddHead(newCAddBomb());if(myPlane.score%600==0&&level!=1&&level!=2)listlboss.AddHead(newCLittleBoss());if(myPlane.score==3630)listboss.AddHead(newCBoss());listEnemy.RemoveAt(pos1);listBomb.RemoveAt(pos2);deletepEnemy;//刪除爆炸的對象deletepBomb;break;}}}for(posBomb2=listBomb2.GetHeadPosition();(pos3=posBomb2)!=NULL;){CBomb2*pBomb2=(CBomb2*)listBomb2.GetNext(posBomb2);for(posEnemy=listEnemy.GetHeadPosition();(pos1=posEnemy)!=NULL;){CRectintersectRect;CEnemy*pEnemy=(CEnemy*)listEnemy.GetNext(posEnemy);intsect=intersectRect.IntersectRect(pEnemy->GetRect(),pBomb2->GetRect());if(sect!=0){CRecteRect;eRect=pEnemy->GetRect();listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));myPlane.score+=30;if(myPlane.score%510==0)listAddblood.AddHead(newCAddBlood());if(myPlane.score%900==0&&level!=1)listaddbomb.AddHead(newCAddBomb());if(myPlane.score%600==0&&level!=1&&level!=2)listlboss.AddHead(newCLittleBoss());if(myPlane.score==3630)listboss.AddHead(newCBoss());listEnemy.RemoveAt(pos1);listBomb2.RemoveAt(pos3);deletepEnemy;deletepBomb2;break;}}}//戰(zhàn)機導(dǎo)彈擊中小BossPOSITIONposa=NULL;//刪除敵機POSITIONpose=NULL,posc=NULL;//刪除導(dǎo)彈for(posBomb=listBomb.GetHeadPosition();(pose=posBomb)!=NULL;){CBomb*pBomb=(CBomb*)listBomb.GetNext(posBomb);for(poslboss=listlboss.GetHeadPosition();(posa=poslboss)!=NULL;){CRectintersectRect;CLittleBoss*plboss=(CLittleBoss*)listlboss.GetNext(poslboss);intintersectSection=intersectRect.IntersectRect(plboss->GetRect(),pBomb->GetRect());if(intersectSection!=0){CRecteRect;eRect=plboss->GetRect();myPlane.score+=30;if(myPlane.score%510==0)listAddblood.AddHead(newCAddBlood());if(myPlane.score%900==0&&level!=1)listaddbomb.AddHead(newCAddBomb());if(myPlane.score%600==0&&level!=1&&level!=2)listlboss.AddHead(newCLittleBoss());if(myPlane.score==3630)listboss.AddHead(newCBoss());if(plboss->lblood>0){plboss->lblood-=5;if(plboss->lblood<=0){listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));plboss->lblood=0;listlboss.RemoveAt(posa);deleteplboss;}}listBomb.RemoveAt(pose);//刪除爆炸的對象deletepBomb;break;}}}for(posBomb2=listBomb2.GetHeadPosition();(posc=posBomb2)!=NULL;){CBomb2*pBomb2=(CBomb2*)listBomb2.GetNext(posBomb2);for(poslboss=listlboss.GetHeadPosition();(posa=poslboss)!=NULL;){CRectintersectRect;CLittleBoss*plboss=(CLittleBoss*)listlboss.GetNext(poslboss);intsect=intersectRect.IntersectRect(plboss->GetRect(),pBomb2->GetRect());if(sect!=0){CRecteRect;eRect=plboss->GetRect();myPlane.score+=30;if(myPlane.score%510==0)listAddblood.AddHead(newCAddBlood());if(myPlane.score%900==0&&level!=1)listaddbomb.AddHead(newCAddBomb());if(myPlane.score%600==0&&level!=1&&level!=2)listlboss.AddHead(newCLittleBoss());if(myPlane.score==3630)listboss.AddHead(newCBoss());if(plboss->lblood>0){plboss->lblood-=5;if(plboss->lblood<=0){listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));plboss->lblood=0;listlboss.RemoveAt(posa);deleteplboss;}}listBomb2.RemoveAt(posc);deletepBomb2;break;}}}戰(zhàn)機導(dǎo)彈擊中大Boss的原理基本與戰(zhàn)機擊中小Boss的相同,故此部分代碼不再給出//戰(zhàn)機撞到敵機POSITIONposEnemy=listEnemy.GetHeadPosition();POSITIONpos=NULL;//刪除戰(zhàn)機和敵機for(posEnemy;(pos=posEnemy)!=NULL;){CEnemy*pEnemy=(CEnemy*)listEnemy.GetNext(posEnemy);pEnemy->Draw(&m_mDC,FALSE);CRectrect;intsection=rect.IntersectRect(pEnemy->GetRect(),myPlane.GetRect());if(section!=0){CPointpoint=myPlane.GetPoint();CRecteRect=pEnemy->GetRect();listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));explosion.Draw(&m_mDC,FALSE);if(myPlane.blood>0){myPlane.blood-=5;if(myPlane.blood<=0&&myPlane.life>1){myPlane.life-=1;myPlane.blood=50+myPlane.blood;}elseif(myPlane.blood<=5&&myPlane.life==1){myPlane.blood=0;myPlane.life=0;}}CObject*d;d=listEnemy.GetAt(pos);listEnemy.RemoveAt(pos);deleted;break;}}//戰(zhàn)機撞到小BossPOSITIONposlboss=listlboss.GetHeadPosition(),posb=NULL;for(poslboss;(posb=poslboss)!=NULL;){CLittleBoss*plboss=(CLittleBoss*)listlboss.GetNext(poslboss);plboss->Draw(&m_mDC,FALSE);CRectrect;intsection=rect.IntersectRect(plboss->GetRect(),myPlane.GetRect());if(section!=0){CRecteRect=myPlane.GetRect();listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));explosion.Draw(&m_mDC,FALSE);if(myPlane.blood>0){myPlane.blood-=5;if(myPlane.blood<=0&&myPlane.life>1){myPlane.life-=1;myPlane.blood=50+myPlane.blood;}if(myPlane.blood<=5&&myPlane.life==1){myPlane.blood=0;myPlane.life=0;}}if(plboss->lblood>0){plboss->lblood-=5;if(plboss->lblood<=0){plboss->lblood=0;listlboss.RemoveAt(posb);deleteplboss;break;}}}}//戰(zhàn)機撞到大BossPOSITIONposboss=listboss.GetHeadPosition(),pos7=NULL;for(posboss;(pos7=posboss)!=NULL;){CBoss*pboss=(CBoss*)listboss.GetNext(posboss);pboss->Draw(&m_mDC,FALSE);CRectrect;intsection=rect.IntersectRect(pboss->GetRect(),myPlane.GetRect());if(section!=0){CRecteRect=myPlane.GetRect();listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));explosion.Draw(&m_mDC,FALSE);if(myPlane.blood>0){myPlane.blood-=20;if(myPlane.blood<=0&&myPlane.life>1){myPlane.life-=1;myPlane.blood=50+myPlane.blood;}if(myPlane.blood<=5&&myPlane.life==1){myPlane.blood=0;myPlane.life=0;}}if(pboss->bblood>0){pboss->bblood-=1;bossblood-=1;if(pboss->bblood<=0){listboss.RemoveAt(pos7);deletepboss;break;}}}}//敵機,小Boss發(fā)射炮彈擊中戰(zhàn)機POSITIONposBall=listBall.GetHeadPosition();POSITIONpos6=NULL;for(posBall;(pos6=posBall)!=NULL;){CBall*pBall=(CBall*)listBall.GetNext(posBall);pBall->Draw(&m_mDC,FALSE);//戰(zhàn)機被敵機的炸彈打到時,戰(zhàn)機和炸彈都刪除CRectintersectRect;intintersectSection=intersectRect.IntersectRect(myPlane.GetRect(),pBall->GetRect());CPointpt=myPlane.GetPoint();CPointpt4=eBall.GetPoint();if(intersectSection!=0){//爆炸效果CRecteRect;eRect=myPlane.GetRect();listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));//從鏈表中刪除并釋放爆炸了的對象。if(myPlane.blood>0){myPlane.blood-=10;if(myPlane.blood<=0&&myPlane.life>1){myPlane.life-=1;myPlane.blood=50+myPlane.blood;}elseif(myPlane.blood<=5&&myPlane.life==1)myPlane.blood=0;{myPlane.life=0;}}listBall.RemoveAt(pos6);deletepBall;break;}}//大Boss發(fā)射炮彈擊中戰(zhàn)機POSITIONposbossball=listbossball.GetHeadPosition();POSITIONpos11=NULL;for(posbossball;(pos11=posbossball)!=NULL;){CBossBall*pbossball=(CBossBall*)listbossball.GetNext(posbossball);pbossball->Draw(&m_mDC,FALSE);//戰(zhàn)機被敵機的炸彈打到時,戰(zhàn)機和炸彈都刪除CRectRect;intSection=Rect.IntersectRect(myPlane.GetRect(),pbossball->GetRect());if(Section!=0){//爆炸效果CRecteRect;eRect=myPlane.GetRect();listExplosion.AddTail(newCExplosion(eRect.left,eRect.top));//從鏈表中刪除并釋放爆炸了的對象。if(myPlane.blood>0)myPlane.blood-=10;{if(myPlane.blood<=0&&myPlane.life>1){myPlane.life-=1;myPlane.blood=50+myPlane.blood;}elseif(myPlane.blood<=5&&myPlane.life==1){myPlane.blood=0;myPlane.life=0;}}listbossball.RemoveAt(pos11);deletepbossball;break;}}補充說明模塊名稱模塊名稱窗口顯示信息功能描述顯示各類信息數(shù)據(jù)結(jié)構(gòu)數(shù)據(jù)結(jié)構(gòu)與算法CDC*pDC=GetDC();//通過GetDC函數(shù)創(chuàng)建了一個CDC類型對象,如此你就可以通過指針名pDC訪問這個對象的成員函數(shù)CRectrect;//包含用于定義矩形的左上角GetClientRect(&rect);//獲取的是以其自身的最左上角的點為坐標(biāo)原點,即窗口左上角為坐標(biāo)原點CDCm_mDC;//內(nèi)存DC緩沖DCm_mDC.CreateCompatibleDC(pDC);//創(chuàng)建與指定設(shè)備兼容的內(nèi)存設(shè)備上下文環(huán)境DCCBitmapmBack;mBack.LoadBitmapW(IDB_dark);m_mDC.SelectObject(&mBack);background.draw(&m_mDC,FALSE);if(myPlane.blood!=0&&myPlane.life!=0)myPlane.Draw(&m_mDC,FALSE);explosion.Draw(&m_mDC,FALSE);m_mDC.TextOutW(0,0,_T("積分:"));CStringt;t.Format(_T("%d"),myPlane.score);m_mDC.TextOutW(40,0,t);m_mDC.TextOutW(0,40,_T("戰(zhàn)機生命值:"));t.F
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026年黃河水利職業(yè)技術(shù)學(xué)院高職單招職業(yè)適應(yīng)性測試備考題庫帶答案解析
- 2026年江蘇財會職業(yè)學(xué)院高職單招職業(yè)適應(yīng)性考試模擬試題帶答案解析
- 2026年上海建橋?qū)W院單招職業(yè)技能考試備考試題帶答案解析
- 2026年云南林業(yè)職業(yè)技術(shù)學(xué)院單招職業(yè)技能筆試備考題庫帶答案解析
- 2026年臨沂職業(yè)學(xué)院高職單招職業(yè)適應(yīng)性測試備考試題帶答案解析
- 【彎道超車】Unit 4 Fun in the Sun!核心語法之play和play with的用法辨析-2025年仁愛科普版(2024)新七年級英語上冊精講精練 (含答案解析)
- Unit 5 Animals and us知識點梳理 -滬教版 六年級英語上冊
- 2026年碳監(jiān)測評估試點項目投資計劃書
- 電路課程題目及答案
- 打火匣題目及答案
- 教師三筆字培訓(xùn)課件
- 河南省百師聯(lián)盟2025-2026學(xué)年高一上12月聯(lián)考英語試卷(含解析含聽力原文及音頻)
- 污水管道更換工程施工方案
- 2025廣東深圳市光明區(qū)事業(yè)單位選聘博士20人筆試備考試題及答案解析
- 租戶加裝充電樁免責(zé)補充合同(房東版)
- 甘肅省天水市2024-2025學(xué)年九年級上學(xué)期期末考試物理試題(含答案)
- 2025年佛山市均安鎮(zhèn)專職消防隊招聘消防員5人備考題庫及1套參考答案詳解
- 2026年海南衛(wèi)生健康職業(yè)學(xué)院單招職業(yè)技能考試題庫參考答案詳解
- 法制副校長課件
- 紅色大氣2026馬年期末匯報展示
- 2026年及未來5年市場數(shù)據(jù)中國釣具市場競爭策略及行業(yè)投資潛力預(yù)測報告
評論
0/150
提交評論