飞机大战实训报告2Word格式文档下载.docx

上传人:b****3 文档编号:6268348 上传时间:2023-05-06 格式:DOCX 页数:39 大小:80.63KB
下载 相关 举报
飞机大战实训报告2Word格式文档下载.docx_第1页
第1页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第2页
第2页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第3页
第3页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第4页
第4页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第5页
第5页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第6页
第6页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第7页
第7页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第8页
第8页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第9页
第9页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第10页
第10页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第11页
第11页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第12页
第12页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第13页
第13页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第14页
第14页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第15页
第15页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第16页
第16页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第17页
第17页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第18页
第18页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第19页
第19页 / 共39页
飞机大战实训报告2Word格式文档下载.docx_第20页
第20页 / 共39页
亲,该文档总共39页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

飞机大战实训报告2Word格式文档下载.docx

《飞机大战实训报告2Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《飞机大战实训报告2Word格式文档下载.docx(39页珍藏版)》请在冰点文库上搜索。

飞机大战实训报告2Word格式文档下载.docx

为了让游戏场景更加逼真,游戏节奏更加合理,可以通过让背景滚动来提高游戏的场景效应,实现这一技术时,可以将一张背景图片复制为2张,从上到下连续的拼接在一起,使其不会出现图片的卡顿和瞬移现象。

2.5内存释放技术

这个程序中有大量的地方需要使用内存,如果不及时删除会出现闪图等情况,容易导致程序崩溃,要及时释放内存资源。

3.总体设计与详细设计

3.1系统模块划分

3.2主要功能模块

类关系图:

4.编码实现

//PlaneGameView.cpp:

CPlaneGameView类的实现

voidCPlaneGameView:

:

UpdateFrame(CDC*pMemDC)

{

//绘制天空

if(level==0)

{

CPaintDCdc(this);

CBitmapbmpBackground;

//位图对象

bmpBackground.LoadBitmap(IDB_BITMAP1);

CDCdcMem;

//定义一个工具箱(设备上下文)

dcMem.CreateCompatibleDC(&

dc);

BITMAPbitmap;

bmpBackground.GetBitmap(&

bitmap);

//建立绑定关系

CBitmap*back=dcMem.SelectObject(&

bmpBackground);

//保存原有CDC对象,并选入新CDC对象入DC

staticintcurr=1;

if(curr<

=1)

curr=GAME_HEIGHT-1;

curr-=1;

pMemDC->

BitBlt(0,0,GAME_WIDTH,GAME_HEIGHT-curr,&

dcMem,0,curr,SRCCOPY);

BitBlt(0,GAME_HEIGHT-curr,GAME_WIDTH,curr,&

dcMem,0,0,SRCCOPY);

}

if(level>

=1&

&

l==0&

boss==0)

FillSolidRect(0,0,GAME_WIDTH,GAME_HEIGHT,RGB(0,0,0));

l++;

z=1;

if(level==1&

l!

=0&

boss!

=0)

CPaintDCdc(this);

CBitmapbmpBackground;

bmpBackground.LoadBitmap(IDB_BITMAP1);

CDCdcMem;

dcMem.CreateCompatibleDC(&

BITMAPbitmap;

bmpBackground.GetBitmap(&

CBitmap*back=dcMem.SelectObject(&

staticintcurr=1;

if(curr<

curr=GAME_HEIGHT-1;

curr-=1;

pMemDC->

if(level==2&

l!

=0&

boss!

=0)

bmpBackground.LoadBitmap(IDB_MAP2);

if(level==3&

bmpBackground.LoadBitmap(IDB_MAP3);

}

if(level==4&

bmpBackground.LoadBitmap(IDB_MAP4);

//兼容

if(level==5&

bmpBackground.LoadBitmap(IDB_MAP5);

5&

bmpBackground.LoadBitmap(IDB_MAP6);

SetBkMode(TRANSPARENT);

SetTextAlign(TA_CENTER);

SetTextColor(RGB(255,255,255));

wchar_tS8[1000];

wsprintf(S8,L"

单击鼠标进入游戏"

);

TextOutW(GAME_WIDTH/2,GAME_HEIGHT/2,CString(S8));

z!

wchar_tS9[1000];

wsprintf(S9,L"

点击进入下一关"

TextOutW(GAME_WIDTH/2,GAME_HEIGHT/2,CString(S9));

z==0)

{wchar_tS1[1000];

wchar_tS2[1000];

wsprintf(S1,L"

得分:

%d"

number);

wsprintf(S2,L"

关卡:

level);

TextOutW(35,0,CString(S1));

TextOutW(200,0,CString(S2));

wchar_tS3[1000];

wsprintf(S3,L"

按下“F1”开启无敌模式"

TextOutW(390,0,CString(S3));

wchar_tS4[1000];

wsprintf(S4,L"

按下“F2”关闭无敌模式"

TextOutW(390,20,CString(S4));

wchar_tS5[1000];

if(wu==0)

{wsprintf(S5,L"

大招数量:

dazhao);

TextOutW(430,40,CString(S5));

}

if(wu==1)

wsprintf(S5,L"

无限"

wchar_tS6[1000];

wsprintf(S6,L"

按下空格发射子弹"

TextOutW(60,50,CString(S6));

wchar_tS7[1000];

wsprintf(S7,L"

按下“Z”大招"

TextOutW(56,70,CString(S7));

//绘制我方战机

if(m_pMe!

=NULL)

m_pMe->

Draw(m_pMemDC,FALSE);

else

{//GameOver

CStringstr=_T("

GameOver!

"

TextOut(GAME_WIDTH/2,GAME_HEIGHT/2,str);

//绘制血条

CStringz1;

z1.Format(L"

战机HP(%d)"

shengming);

TextOut(47,30,z1);

pMemDC->

FillSolidRect(90,33,shengming*10,10,RGB(255,0,0));

if(bxt==1)

{

CStringz2;

z2.Format(L"

BossHP(%d)"

boss);

TextOut(35,100,z2);

FillSolidRect(80,108,boss*2,10,RGB(0,255,0));

//绘制导弹、爆炸、敌机、子弹、boss、boss子弹

for(inti=0;

i<

=8;

i++)

POSITIONpos1,pos2;

for(pos1=m_ObjList[i].GetHeadPosition();

(pos2=pos1)!

=NULL;

CGameObject*pObj=(CGameObject*)m_ObjList[i].GetNext(pos1);

if(pObj&

!

pObj->

Draw(pMemDC,FALSE))

{

m_ObjList[i].RemoveAt(pos2);

deletepObj;

}

}}

//复制内存DC到设备DC

m_pDC->

BitBlt(0,0,GAME_WIDTH,GAME_HEIGHT,m_pMemDC,0,0,SRCCOPY);

AI()

staticintnCreator=rand()%5+20;

//随机产生敌机

if(nCreator<

nCreator=rand()%5+20;

m_ObjList[enEnemy].AddTail(newCEnemy);

nCreator--;

//随机产生大招

if(count%30==0)

m_ObjList[endazhao].AddTail(newCda);

count++;

//随机产生生命

if(count%40==0)

m_ObjList[enming].AddTail(newCshengming);

//产生boss

if(level==1&

bn==0&

count>

=25&

count<

=27)

m_ObjList[enboss].AddTail(newCboss);

bxt=1;

bn++;

if(level==2&

=50&

=52)

if(level==3&

=75&

=77)

if(level==4&

=100&

=102)

if(level==5&

=150&

=152)

bn++;

if(level>

5&

count%200==0&

bn==0)

if(m_pMe==NULL)

return;

//检测四个方向键,移动战机

i<

4;

intnMeMotion=0;

SetVerMotion(0);

SetHorMotion(0);

nMeMotion=GetKey(VK_UP);

if(nMeMotion==1)

m_pMe->

SetVerMotion

(1);

nMeMotion=GetKey(VK_DOWN);

SetVerMotion(-1);

nMeMotion=GetKey(VK_RIGHT);

SetHorMotion

(1);

nMeMotion=GetKey(VK_LEFT);

SetHorMotion(-1);

//产生战机导弹

if(GetKey(VK_SPACE)==1)//按下了空格键

if(m_pMe!

=NULL&

m_pMe->

Fired())

CPointpt=m_pMe->

GetPoint();

if(level==1&

wu==0)

m_ObjList[enBomb].AddTail(newCBomb(pt.x+20,pt.y+10));

if(level==2&

m_ObjList[enBomb].AddTail(newCBomb(pt.x+10,pt.y+30));

m_ObjList[enBomb].AddTail(newCBomb(pt.x+30,pt.y+30));

if(level==3&

m_ObjList[enBomb].AddTail(newCBomb(pt.x+10,pt.y+30));

m_ObjList[enBomb].AddTail(newCBomb(pt.x+30,pt.y+30));

m_ObjList[enBomb].AddTail(newCBomb(pt.x+20,pt.y+30));

if(level>

=4&

m_ObjList[enBomb].AddTail(newCBomb(pt.x+20,pt.y+30)

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2