C++源代码游戏编程---WinMain()函数集(转)[@more@]
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 PASCAL
WinMain(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 PASCAL
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
if (InitApp(hInstance, nCmdShow) != DD_OK)
return FALSE;
Map[0].Width=width;
Map[0].Hight=height;
Map[0].Data=(char *)malloc( Map[0].Width * Map[0].Hight );
Map[0].Pro=(char *)malloc( Map[0].Width * Map[0].Hight );
//将地图全部置为可到达
int i,j;
reachable=1;
for (j=0;j
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8225414/viewspace-951669/
,如需转载,请注明出处,否则将追究法律责任。