飞机大战实验报告Word文档格式.docx

上传人:b****3 文档编号:15755113 上传时间:2022-11-15 格式:DOCX 页数:18 大小:21.12KB
下载 相关 举报
飞机大战实验报告Word文档格式.docx_第1页
第1页 / 共18页
飞机大战实验报告Word文档格式.docx_第2页
第2页 / 共18页
飞机大战实验报告Word文档格式.docx_第3页
第3页 / 共18页
飞机大战实验报告Word文档格式.docx_第4页
第4页 / 共18页
飞机大战实验报告Word文档格式.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

飞机大战实验报告Word文档格式.docx

《飞机大战实验报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《飞机大战实验报告Word文档格式.docx(18页珍藏版)》请在冰豆网上搜索。

飞机大战实验报告Word文档格式.docx

GetRect();

GetPoint();

指针易于获得某个类的所在的位置,所在的区域、坐标以及图像的绘制

2.2动态链表的应用

链表类型:

例:

定义一个链表CObListlistBoss;

listExplosion.AddTail(newCExplosion(plane.GetRect().left,plane.GetRect().top));

plane.GetRect()通过链表来求出某个类的矩形区域、坐标、以及图形的绘制。

3.总体设计与详细设计

3.1系统模块划分

1、voidCtest2View:

OnDraw(CDC*pDC)

2、voidCtest2View:

OnTimer(UINT_PTRnIDEvent)

3、voidCtest2View:

OnInitialUpdate()

4、voidCtest2View:

OnKeyDown(UINTnChar,UINTnRepCnt,UINTnFlags)

5、voidCtest2View:

OnKeyUp(UINTnChar,UINTnRepCnt,UINTnFlags)

3.2主要功能模块

功能模块分为敌机绘制导弹绘制战机绘制炸弹绘制boss、boss1绘制、爆炸绘制、插入图片、插入声效以及每关boss的筛选。

主要类图:

BALL(炸弹)类BOSS1类BOSS类Enemy(敌机)类Myplane类Explosion类BOMB类

在ontimer里实现对所弹出的icon里所有图像的输出,主要划分为

1、敌机、战机、导弹、boss、背景图片、gameover图片的绘制,以及爆炸声效,结束声效的实现。

2、实现方向键对飞机的控制,实现space以及shift键对导弹发射的控制

4.编码实现

//test2View.cpp:

Ctest2View类的实现

#include"

stdafx.h"

test2.h"

test2Doc.h"

test2View.h"

#pragmacomment(lib,"

winmm.lib"

mmsystem.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#endif

//Ctest2View

IMPLEMENT_DYNCREATE(Ctest2View,CView)

BEGIN_MESSAGE_MAP(Ctest2View,CView)

//标准打印命令

ON_COMMAND(ID_FILE_PRINT,&

CView:

OnFilePrint)

ON_COMMAND(ID_FILE_PRINT_DIRECT,&

ON_COMMAND(ID_FILE_PRINT_PREVIEW,&

OnFilePrintPreview)

ON_WM_TIMER()

//ON_WM_CREATE()

ON_WM_KEYDOWN()

ON_WM_KEYUP()

END_MESSAGE_MAP()

//Ctest2View构造/析构

Ctest2View:

Ctest2View()

{

//TODO:

在此处添加构造代码

}

~Ctest2View()

BOOLCtest2View:

PreCreateWindow(CREATESTRUCT&

cs)

在此处通过修改

//CREATESTRUCTcs来修改窗口类或样式

returnCView:

PreCreateWindow(cs);

//Ctest2View绘制

voidCtest2View:

Ctest2Doc*pDoc=GetDocument();

ASSERT_VALID(pDoc);

if(!

pDoc)

return;

在此处为本机数据添加绘制代码

CRectrect;

GetClientRect(&

rect);

pDC->

Rectangle(rect);

//画边框

CBrushbrush;

brush.CreateSolidBrush(RGB(0,150,255));

//设置背景颜色

CBrush*oldbrush=pDC->

SelectObject(&

brush);

SelectObject(oldbrush);

//Ctest2View打印

OnPreparePrinting(CPrintInfo*pInfo)

{//默认准备

returnDoPreparePrinting(pInfo);

OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)

添加额外的打印前进行的初始化过程

OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)

添加打印后进行的清理过程

//Ctest2View诊断

AssertValid()const

CView:

AssertValid();

Dump(CDumpContext&

dc)const

Dump(dc);

Ctest2Doc*Ctest2View:

GetDocument()const//非调试版本是内联的

ASSERT(m_pDocument->

IsKindOf(RUNTIME_CLASS(Ctest2Doc)));

return(Ctest2Doc*)m_pDocument;

#endif//_DEBUG

//Ctest2View消息处理程序

在此添加消息处理程序代码和/或调用默认值

CDC*pDC=GetDC();

CDCMemDC;

////显示生命值和得分

staticintNum_grade=0;

staticintNum_life=1000000;

staticintm=1;

CClientDCdc(this);

CStringgrade;

CStringlife;

CStringt;

CStringhaha;

CStringlihai;

//消除重叠

CBitmapbmp;

if(Num_life==0)

{PlaySound(TEXT("

xiaoxin.wav"

),NULL,SND_FILENAME|SND_ASYNC);

CBrushm_gameover2;

CBitmapbmp1;

bmp1.LoadBitmap(IDB_gameover2);

///加载位图

m_gameover2.CreatePatternBrush(&

bmp1);

///创建位图画刷

FillRect(rect,&

m_gameover2);

///用背景画刷填充区域

KillTimer

(1);

}

else

{

CBrushm_beijing;

bmp.LoadBitmap(IDB_beijing);

m_beijing.CreatePatternBrush(&

bmp);

m_beijing);

}

SetBkMode(TRANSPARENT);

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

//更改字体颜色

t.Format(L"

第%d关"

m);

TextOutW(10,45,t);

grade.Format(L"

得分:

%d"

Num_grade);

TextOutW(10,30,grade);

life.Format(L"

生命值:

Num_life);

TextOutW(10,15,life);

//-----------------------敌机绘制及战机与敌机碰撞-------------------------------

if(listEnemy.GetCount()<

12)

listEnemy.AddTail(newCEnemy());

POSITIONpos,oldpos;

pos=listEnemy.GetHeadPosition();

while(pos)

{

oldpos=pos;

CEnemy*pEnemy=(CEnemy*)listEnemy.GetNext(pos);

if(!

rect.IntersectRect(pEnemy->

GetRect(),plane.GetRect()))

//判断敌机和战机区域是否有交集

{

pEnemy->

Draw(pDC,TRUE);

intn=rand()%40;

if(n==1)

{

listBall.AddTail(newCBall(pEnemy->

GetPoint().x+12,pEnemy->

GetPoint().y+25,pEnemy->

GetMotion()));

}

else

listExplosion.AddTail(newCExplosion(plane.GetRect().left,plane.GetRect().top));

PlaySound(TEXT("

explosion.wav"

listEnemy.RemoveAt(oldpos);

//消除敌机

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

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1