How do I limit the game loop?

Posted by user1758938 on Game Development See other posts from Game Development or by user1758938
Published on 2012-10-27T13:15:21Z Indexed on 2012/11/01 23:23 UTC
Read the original article Hit count: 458

Filed under:
|
|
|

How do I make a game update at a consistent speed? For example, this would loop too fast:

while(true)  
{    
                   GetInput();  
                   Render();  
}

This just wont work (hard to explain):

while(true)  
{    
                   GetInput();  
                   Render();  
                   Sleep(16);
}

How do I sync my game to a certain framerate and still have input and functions going at a consistent rate?

© Game Development or respective owner

Related posts about c++

Related posts about game-design