




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C+源代码游戏编程-WinMain()函数集 C+源代码游戏编程-WinMain()函数交流/*/函数:WinMain()/功能:应用程序入口/*int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow) MSG msg; hInst=hInstance; /初始化主窗口 if (!InitWindow( hInstance, nCmdShow) return FALSE; /初始化DirectDraw环境 if (!InitDDraw() MessageBox(hWndMain, 初始化DirectDraw过程中出错!, Error, MB_OK); FreeObjects(); DestroyWindow(hWndMain); return FALSE; /进入消息循环 while(1) if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) if(!GetMessage(&msg, NULL, 0, 0 ) return msg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); else if(bActive) UpdateFrame(); else WaitMessage(); return msg.wParam;/-/ Name: WinMain()/ Desc: Initialization, message loop/-int PASCALWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) MSG msg; if (InitApp(hInstance, nCmdShow) != DD_OK) return FALSE; while (GetMessage(&msg, NULL, 0, 0) TranslateMessage(&msg); DispatchMessage(&msg); return msg.wParam;/ 主循环/int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) MSG msg; if(!InitApp(hInst, nCmdShow) return FALSE; while(1) if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) if(!GetMessage(&msg, NULL, 0, 0 ) return msg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); else if(bActive) Update(); / 翻转上一层缓冲区内容到屏幕。 Screen-Flip(); else WaitMessage(); /int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow) / any windows programmer should be familiar with this MSG msg; lpCmdLine = lpCmdLine; hPrevInstance = hPrevInstance; if(!doInit(hInstance, nCmdShow) return FALSE; while (1) if(PeekMessage(&msg, NULL, 0,0,PM_NOREMOVE) if(!GetMessage(&msg, NULL,0,0) return msg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); else if(bActive) fire(480, 0, 600, 50); / draw fire on bottom row and then flip while(1) ddrval = lpDDSPrimary-Flip(NULL, DDFLIP_WAIT); if(ddrval = DD_OK) break; if(ddrval = DDERR_SURFACELOST) if(ddrval != DD_OK) break; if(ddrval != DDERR_WASSTILLDRAWING) break; / if bActive else /make sure we go to sleep if have nothiing to do WaitMessage(); / win main/-/ Name: WinMain()/ Desc: 入口,初始化,进行消息循环/-int PASCALWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) MSG msg; if (InitApp(hInstance, nCmdShow) != DD_OK) return FALSE; Map0.Width=width; Map0.Hight=height; Map0.Data=(char *)malloc( Map0.Width * Map0.Hight ); Map0.Pro=(char *)malloc( Map0.Width * Map0.Hight ); /将地图全部置为可到达 int i,j; reachable=1; for (j=0;jMap0.Hight;j+) for (i=0;iMap0.Width;i+) *(Map0.Data+i*Map0.Hight+j)=reachable; for (j=0;jMap0.Hight;j+) for (i=0;iGetDirectDraw()-SetCooperativeLevel( NULL, DDSCL_NORMAL ); MessageBox( hWnd, TEXT(DirectDraw init failed. ) TEXT(The sample will now exit. ), TEXT(DirectDraw Sample), MB_ICONERROR | MB_OK ); return FALSE; g_dwLastTick = timeGetTime(); while( TRUE ) / Look for messages, if none are found then / update the state and display it if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) if( 0 = GetMessage(&msg, NULL, 0, 0 ) ) / WM_QUIT was posted, so exit return (int)msg.wParam; / Translate and dispatch the message TranslateMessage( &msg ); DispatchMessage( &msg ); else if( g_bActive ) / Move the sprites, blt them to the back buffer, then / flip or blt the back buffer to the primary buffer if( FAILED( ProcessNextFrame() ) ) SAFE_DELETE( g_pDisplay ); MessageBox( hWnd, TEXT(Displaying the next frame failed. ) TEXT(The sample will now exit. ), TEXT(DirectDraw Sample), MB_ICONERROR | MB_OK ); return FALSE;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- DB61 1078-2017 施工场界扬尘排放限值
- 苏轼作品及其生平
- 上海市宝山区2025年数学高三上期末监测模拟试题
- 辽宁省北镇市中学2025年数学高三第一学期期末质量跟踪监视试题
- 江苏省南通市通州区海安县2025-2026学年高三数学第一学期期末经典模拟试题
- 内蒙古鄂尔多斯市达拉特旗第一中学2025-2026学年数学高三第一学期期末质量检测试题
- 营养小组理论考核试题及答案
- 2025内蒙古鄂尔多斯伊金霍洛旗布连矿区消防救援大队招聘4人备考练习试题及答案解析
- 2025太原市小店区招聘劳务派遣教师240人(第二批)备考练习试题及答案解析
- 2025年铜陵市新华山铜业有限责任公司公开招聘工作人员2名补充备考练习题库及答案解析
- 2025年农村商业银行招聘笔试真题及答案(可下载)
- 熏蒸药品管理办法
- 各阶段样件管理办法
- 2025年服务行业技能考试-电教员历年参考题库含答案解析(5套100道单选题合辑)
- 高职院校实训室管理办法
- 收银系统操作培训
- 公务摄影培训课件下载
- 危险化学品生产许可证实施细则(一)(危险化学品无机产品部分)
- 黍离教学课件
- 卓越幼儿园教师健康专题培训课件
- 个股期权培训课件
评论
0/150
提交评论