Game Loops
- In your game loop, you have to make sure the game is refreshing at the interval you want & not as fast as the computer will let it go.
- To wit, you want to take tick readings (in ms) at the beginning of the loop & at the end of the loop.
- I see a lot similar code in game loops that look like this:
- 1000 / FramesPerSecond
- We want to force/coerce our loops to match our preferred FPS, 30 or 60 is popular due to the Hz refresh rates for monitors.
- Don't forget! One frame = One time through your game loop so if we want a frame rate of 60 frames per second...
- We want to update ever 1/60th of a second!
- But since most timing is based in milliseconds, you see 1000/60 in code
- And the 60 is hard-coded, so most programmers will rip it out as a variable. That's why you see 1000 / FramesPerSecond