资源描述:
《C++源代码游戏编程--WinMain()函数集》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、C++源代码游戏编程--WinMain()函数集C++源代码游戏编程--WinMain()函数交流//******************************************************************//函数:WinMain()//功能:应用程序入口//******************************************************************intPASCALWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdS
2、how){ MSGmsg; hInst=hInstance; //初始化主窗口 if(!InitWindow(hInstance,nCmdShow)) returnFALSE; //初始化DirectDraw环境 if(!InitDDraw()) { MessageBox(hWndMain,"初始化DirectDraw过程中出错!","Error",MB_OK); FreeObjects(); DestroyWindow(hWndMain); returnFALSE; } //进入消息循环
3、 while(1) { if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) { if(!GetMessage(&msg,NULL,0,0))returnmsg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); } elseif(bActive) { UpdateFrame(); } elseWaitMessage()
4、; } returnmsg.wParam;} /////////////////////////////////////////////////-----------------------------------------------------------------------------//Name:WinMain()//Desc:Initialization,messageloop//-----------------------------------------------------------------------------intPASC
5、ALWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){ MSGmsg; if(InitApp(hInstance,nCmdShow)!=DD_OK) returnFALSE; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } returnmsg.wParam;}///////////////////
6、////////////////////////////////////////////////////////////////////////////主循环/////////////////////////////////////////////////////////////////////////////////////////////intPASCALWinMain(HINSTANCEhInst,HINSTANCEhPrevInst,LPSTRlpCmdLine,intnCmdShow){ MSGmsg; if(!InitApp(hInst,nCmdShow))
7、returnFALSE; while(1) { if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) { if(!GetMessage(&msg,NULL,0,0))returnmsg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); } elseif(bActive) {