Finding a location for a function that would cause it to get called on a constant basis
-
I tried placing the UpdateGame() function inside the window message processing loop but the execution never reaches that spot
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);} else { UpdateGame(); }
}
I`m trying to mix code from two different tutorials which might be the cause of the problem. Bellow is what the initial message processing loop looked like.
while (GetMessage(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);}
-
I tried placing the UpdateGame() function inside the window message processing loop but the execution never reaches that spot
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);} else { UpdateGame(); }
}
I`m trying to mix code from two different tutorials which might be the cause of the problem. Bellow is what the initial message processing loop looked like.
while (GetMessage(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);}
At a guess
PeekMessage()
is always returning true. If you wantUpdateGame()
to always be called then remove it from theelse
block:while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);} UpdateGame();
}
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
At a guess
PeekMessage()
is always returning true. If you wantUpdateGame()
to always be called then remove it from theelse
block:while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);} UpdateGame();
}
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
Thanks for advice, I’ll give it a try