   visual C 8 game loop
  anyone know how to implement a game loop with the code generated by the win32 app project?   
  something like:while(!done) {  ... Code here ... }?   :)   ;// Main message loop:while (GetMessage(&msg, NULL, 0, 0)) {if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {TranslateMessage(&msg);DispatchMessage(&msg);}}change that to:// Main message loop:while(!done) {while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {TranslateMessage(&msg);DispatchMessage(&msg);}}// Update game hereBut i suggest you reed a tutorial on how to make a real game loop and dont use the app created by windows you have more control if you make your own app..;  Will this work?do{if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)){if (msg.message == WM_QUIT) break;TranslateMessage(&msg);DispatchMessage(&msg);}}else{    //game stuff}}while(TRUE);;Quote:Original post by etsujaWill this work?*** Source Snippet Removed ***Yup.   ;Quote:Original post by etsujaWill this work?*** Source Snippet Removed ***Well, it will work, but is that really how you want it?  (And out of curiousity, why use a do{}while() loop in place of a while() loop or maybe even for()?)But what if you did this:while(true) { // makes my life easier :D    get_message(&message); // don't know win32, help me out here!    switch (message.code) { // again, win32   case QUIT: // need I say it?  break; // oh-oh!   break;   case KEYDOWN:  // super-cool keydown!   break;    }}The break would break the switch, not the while loop....  so I would do instead something like:for (bool done = false; !done; /*none*/) { // makes my life easier :D    get_message(&message); // don't know win32, help me out here!    switch (message.code) { // again, win32   case QUIT: // need I say it?  done = true; // walla!   break;   case KEYDOWN:  // super-cool keydown!   break;    }}Just a heads-up.   ;  Moving to For Beginners.   ;  Just follow SmurfKiller's advice as this is the way I do it and it does the job perfectly.However, You probably will not need the TranslateAccelerator function in your game as this will only be wasted cycles. If you don't intend on processing the WM_CHAR message then you don't need the TranslateMessage function either.;  The best way is simply something like this: -// main game loopwhile(g_pGame->IsRunning()){    // clear the screen    g_pGraphicsManager->ClearScreen();    // get the frame time    float fFrameTime = g_pTimeManager->GetFrameTime();    // get the user input    g_pInputManager->Update(fFrameTime);    // update AI logic    g_pAIManager->Update(fFrameTime);    // update game logic    g_pGame->Update(fFrameTime);    // update audio    g_pAudioManager->Update(fFrameTime);    // render the scene    g_pGraphicsManager->RenderScene(fFrameTime);}This is the normal game loop for a muti-platform, client only game. All of the main computation is taken off and handled by the respective objects.NOTE: The input here will be handled by some for of input API, DirectInput maybe for Win32 systems.   ;  My game loop looks like thisMSG msg = {};while(msg.message != WM_QUIT){    if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))DispatchMessage(&msg);    else   RunFrame();}