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



C源代码游戏编程--WinMain交流

//******************************************************************
//:WinMain
//功能:应用入口
//******************************************************************
PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, nCmdShow)
{
MSG msg;
hInst=hInstance;

//化主窗口
(!InitWindow( hInstance, nCmdShow))
FALSE;

//化DirectDraw环境
(!InitDDraw)
{
MessageBox(hWndMain, \"化DirectDraw过程中出错!\", \"Error\", MB_OK);
FreeObjects;
DestroyWindow(hWndMain);
FALSE;
}

//进入消息循环
while(1)
{
(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
(!GetMessage(&msg, NULL, 0, 0 )) msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
(bActive)
{
UpdateFrame;
}
WaitMessage;
}

msg.wParam;
}

///////////////////////////////////////////////


//-----------------------------------------------------------------------------
// Name: WinMain
// Desc: Initialization, message loop
//-----------------------------------------------------------------------------
PASCAL
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
nCmdShow)
{
MSG msg;

(InitApp(hInstance, nCmdShow) != DD_OK)
FALSE;

while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
msg.wParam;
}

/////////////////////////////////////////////////////////////////////////////////////////////
// 主循环
/////////////////////////////////////////////////////////////////////////////////////////////
PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, nCmdShow)
{
MSG msg;


(!InitApp(hInst, nCmdShow)) FALSE;

while(1)
{
(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
(!GetMessage(&msg, NULL, 0, 0 )) msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
(bActive)
{
Update;

// 翻转上层缓冲区内容到屏幕
Screen->Flip;
}
WaitMessage;
}
}
////////////////////////////////////////////////

///////////////////////////////////////////////////
PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, nCmdShow)
{
// any windows programmer should be familiar with this

MSG msg;

lpCmdLine = lpCmdLine;
hPrevInstance = hPrevInstance;
(!doInit(hInstance, nCmdShow))
{
FALSE;
}

while (1)
{
(PeekMessage(&msg, NULL, 0,0,PM_NOREMOVE))
{
(!GetMessage(&msg, NULL,0,0))
msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
(bActive)
{
fire(480, 0, 600, 50);
// draw fire _disibledevent=>(ddrval DD_OK)
{
;
}
(ddrval DDERR_SURFACELOST)
{
(ddrval != DD_OK)
{
;
}
}
(ddrval != DDERR_WASSTILLDRAWING)
{
;
}
}
} // bActive

{
//make sure we go to sleep have nothiing to do
WaitMessage;
}
}

} // win


//////////////////////////////////////////////

//-----------------------------------------------------------------------------
// Name: WinMain
// Desc: 入口,进行消息循环
//-----------------------------------------------------------------------------
PASCAL
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
nCmdShow)
{
MSG msg;

(InitApp(hInstance, nCmdShow) != DD_OK)
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 );

//将地图全部置为可到达
i,j;
reachable=1;
for (j=0;j<Map[0].Hight;j)
for (i=0;i<Map[0].Width;i)
{
*(Map[0].Data+i*Map[0].Hight+j)=reachable;
}

for (j=0;j<Map[0].Hight;j)
for (i=0;i<Map[0].Width;i)
{
*(Map[0].Pro+i*Map[0].Hight+j)=select_pro;
}

//消息循环
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

msg.wParam;
}

//-----------------------------------------------------------------------------
// Name: WinMain
// Desc: Entry po to the program. Initializes everything and calls
// UpdateFrame when idle from the message pump.
//-----------------------------------------------------------------------------
APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, nCmdShow )
{


MSG msg;
HWND hWnd;

ZeroMemory( &g_Sprite, (SPRITE_STRUCT) * NUM_SPRITES );
srand( GetTickCount );

( FAILED( WinInit( hInst, nCmdShow, &hWnd ) ) )
FALSE;

// Make a timer go off to re-init the table of random values every _disibledevent=>
while( TRUE )
{
// Look for messages, none are found then
// update the state and display it
( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
( 0 GetMessage(&msg, NULL, 0, 0 ) )
{
// WM_QUIT was posted, so exit
()msg.wParam;
}

// Translate and dispatch the message
TranslateMessage( &msg );
DispatchMessage( &msg );
}

{
( g_bActive )
{
// Move the sprites, blt them to the back buffer, then
// flip or blt the back buffer to the primary buffer
( 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 );
FALSE;
}
}

{
// Make sure we go to sleep we have nothing to do
WaitMessage;

// Ignore time spent inactive
g_dwLastTick = timeGetTime;
}
}
}
}

本人e-mail: fuzipin@sina,com
希望通过交流进步提高我们游戏开发水平OK

Tags:  编程源代码 率失真函数源代码 c库函数源代码 winmain函数

延伸阅读

最新评论

发表评论