1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| MSG msg;
// Start the game loop
for(;;)
{
// Handle dialog messages if present
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
// Check for game exit
if( WM_QUIT == msg.message )
break;
if( !IsDialogMessage( g_hDlg, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
{
// Send outgoing network data
if( g_bConnected || g_bHosting )
SendDirectPlayMessage();
// Handle incoming network data
// Here we're setting the allowed timeslice at 100 milliseconds.
// The program will block while DoWork handles network communication
// so we don't need to worry about thread synchronization issues as
// we have on earlier tutorials.
g_pThreadPool->DoWork( 100, 0 );
// Render the scene
Render();
// Yield some time for other processes
Sleep( 10 );
}
} |
Partager