Here is my now working message loop, thanks to Hunter2's old space shooter game. I am using PeekMessage, and his little nifty Sleep() thingy which I don't understand:
Code:
while(!done)
{
DWORD start, timeElapsed;
start = GetTickCount();
while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
MainFunc(hWnd);
timeElapsed = GetTickCount() - start;
if(timeElapsed < FRAME_DELAY)
Sleep(FRAME_DELAY - timeElapsed);
}
if I don't have that if-statement in there, the timeElapsed one, it doesn't work good. if i keep it in it works great. could anyone explain what exactly that is doing?
lol im sure you could, Hunter