Monday, May 9, 2016

Questions About Game Loops


I've been reading up how to lay out a game loop that'll work optimally in both great and not so great conditions but I think I've confused a few techniques together... so I have some questions...




  1. Fixed Physics Step: If I fix my physics step because determinism is important in my game, and at some point the game falls behind and needs to catch up, would I need to update multiple times or is there a safe method of updating physics by double or triple steps? If I'm rolling my own physics should I write them in a particular way to facilitate this?

  2. Input: If I need to update multiple times before the next frame should I check the input before updating each time or check once and leave the input for the next tick after that to handle?

  3. Updating: How often do I really need to update a game so no lag is felt by the player? It seems like you can get away with well under 60tps but at what point do players feel the delay? Are there any drawbacks to updating less frequently than rendering?

  4. Networked: If the game is networked through an authoritative server, would all machines have to update their client side predictive movement code at the same rate as the server to avoid constant visible repositioning or would the difference be minimal and virtually undetectable if I resolve potential jittering with smooth position correction?

  5. Interpolation: Would interpolating the position of drawn objects between updates be something I'd only need to do if my game updated at a much slower rate than my fps or is it good to interpolate anyway? What would interpolating involve? Running another partial position update just before the draw or updating the next position in advance and using the partial step percentage (time passed sine last update) to advance positions that percentage between the current and next steps?

  6. Render Timing: Is there a way (or a need) to draw a frame at the last moment before the screen refreshes?

  7. Sleeping: After a draw when I don't yet need to update I should hand the thread back over to the OS, yeah? If I'm making a cross-platform game and some operating systems might wake my thread up a little earlier or later than I've specified is there a chance that might affect the game at all if my physics is fixed?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...