C++源代码游戏编程--WinMain()函数集.doc

上传人:asd****56 文档编号:70344298 上传时间:2023-01-19 格式:DOC 页数:7 大小:38.50KB
返回 下载 相关 举报
C++源代码游戏编程--WinMain()函数集.doc_第1页
第1页 / 共7页
C++源代码游戏编程--WinMain()函数集.doc_第2页
第2页 / 共7页
点击查看更多>>
资源描述

《C++源代码游戏编程--WinMain()函数集.doc》由会员分享,可在线阅读,更多相关《C++源代码游戏编程--WinMain()函数集.doc(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、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(

2、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

3、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

4、(&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.wPara

5、m; 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 =

6、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

7、 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/-/ Na

8、me: 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 *

9、)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.

10、) 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, NUL

11、L, 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( Process

12、NextFrame() ) ) 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; else / Make sure we go to sleep if we have nothing else to do WaitMessage(); / Ignore time spent inactive g_dwLastTick = timeGetTime(); 本人e-mail: fuzipinsina,com希望通过交流进一步提高我们的游戏开发水平,OK

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁