Skip to main content
gamedev.net
🔒 Locked

Time based movement problem

Started by -Tony- 2 replies 600+ views
Original Post
-Tony-
-Tony-
When you move the game window around for a while, delta time gets really high and then the game characters move too much and gets stuck sometimes. How do you fix this? this is the game loop

while(!Window.IsClosed())
 {
  if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
  {
   TranslateMessage(&Msg);
   DispatchMessage(&Msg);
  }
  else if(Window.IsVisible())
  {
   CalculateFps();

   if(!Game.Process(Timer.GetTime(), DeltaTime))
    break;

   Window.Swap();
  }
  else
  {
   CalculateFps();
   WaitMessage();
  }
 }

psykr
psykr
How about pausing the game while the window is moving? Or if you dig into MSDN enough, I bet there''s a way to keep the app rendering while you''re moving it around.
jamessharpe
jamessharpe
Try removing the call to wait message. Then, if there are no messages waiting, your loop will continue, instead of waiting for a new message, thus keeping the delta up to date.

You may also find that changing the if(PeekMessage(..) ) to while(PeekMessage(..) ) will result in a more responsive app.

Generally in game apps you never call WaitMessage, since you don't want to be waiting for a message from windows, you want to be doing something else, like making the AI think, or rendering, or any other task you find you may want to do.

[edited by - jamessharpe on September 6, 2003 2:32:02 PM]
JohnBolton
JohnBolton
Try turning off this checkbox: Control Panel > Display > Appearance > Effects... > "Show window contents while dragging".

jamessharpe: WaitMessage() probably is not a problem since it is only called if IsVisible() returns false.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.