作业中存在的典型问题.ppt

  1. 1、本文档共45页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
作业中存在的典型问题.ppt

5. 为了实现陨石的自动下落运动,需要添加定时器函数来控制。 方法: 1) 选View|ClassWizard菜单项,在MFC ClassWizard中,选择CPlaneView类,在Message Maps选项卡中的Messages栏目选择WM_TIMER、WM_CREATE消息, 分别双击该项,由系统自动生成该对应的消息函数。如图示: 2) 在CPlaneView类的OnTimer函数和OnCreate函数中添加相应的代码,使陨石产生下落的效果。 在OnCreate函数中添加:SetTimer(1,200,NULL);//定时器 在OnTimer 函数中添加: CClientDC ClientDC(this); RECT ClientRect; GetClientRect(ClientRect); RECT rect1,rect2,rect3,rect4,rect5; BITMAP bm; m_stone1.GetObject(sizeof(BITMAP),bm); CBrush brush(GetSysColor(COLOR_WINDOW)); int n=0,ns1,ns2,ns3,ns4,ns5; n++; ns1=nstone1x+n; rect1.left=ns1-20; rect1.top=nstone1y-20; rect1.right=rect1.left+bm.bmWidth; rect1.bottom=rect1.top+bm.bmHeight; ClientDC.FillRect(rect1,brush); nstone1y=nstone1y+10; // 陨石1 下落的速度 if(nstone1yClientRect.bottom) {nstone1y=0; nstone1x=rand()%ClientRect.right; // 陨石落下的位置随机产生 } ns2=nstone2x+n; rect2.left=ns2-20; rect2.top=nstone2y-20; rect2.right=rect2.left+bm.bmWidth+10; rect2.bottom=rect2.top+bm.bmHeight+10; ClientDC.FillRect(rect2,brush); nstone2y=nstone2y+13; if(nstone2yClientRect.bottom) {nstone2y=0; nstone2x=rand()%ClientRect.right; } ns3=nstone3x+n; rect3.left=ns3-20; rect3.top=nstone3y-20; rect3.right=rect3.left+bm.bmWidth+10; rect3.bottom=rect3.top+bm.bmHeight+10; ClientDC.FillRect(rect3,brush); nstone3y=nstone3y+15; if(nstone3yClientRect.bottom) {nstone3y=0; nstone3x=rand()%ClientRect.right; } ns4=nstone4x+n; rect4.left=ns4-20; rect4.top=nstone4y-20; rect4.right=rect4.left+bm.bmWidth+10; rect4.bottom=rect4.top+bm.bmHeight+10; ClientDC.FillRect(rect4,brush); nstone4y=nstone4y+17; if(nstone4yClientRect.bottom) {nstone4y=0; nstone4x=rand()%ClientRect.right; } ns5=nstone5x+n; rect5.left=ns5-20; rect5.top=nstone5y-20; rect5.right=rect5.left+bm.bmWidth+10; rect5.bottom=rect5.top+bm.bmHeight+10; ClientDC.FillRect(rect5,brush); nstone5y=nstone5y+19; if(nstone5yClientRect.bottom) {nstone5y=0; nstone5x=rand()%ClientRect

文档评论(0)

170****0532 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8015033021000003

1亿VIP精品文档

相关文档