Here's a novel idea I just thought of. . . I haven't tried this and I'm not sure if it would work, but what if. . .
1) you set an optimal framerate, say 35 fps
2) each loop you randomly either draw a frame or update the logic.
3) keep track of the frame rate
4) if the framerate exceeds the optimal, then slightly increase the chance of updating logic / decrease chance of rendering and vica versa
5) set limits (probably best based on a mininum # of updates per sec) so that it doesn't become impossible to render or update.
6) use delta timing in your update loop to keep movement consistant.
That way you should be able to run at near enough your optimal frame rate and update as much as is possible at that framerate with no time loss. You would also easily allow the user to adjust their optimal framerate - so a slow computer could use an optimal of say 20 fps etc and the physics would therefore not suffer, and someone with a super fast computer could run as fast as they are able to, without the loss of update accuracy.
I think I'll try this and see if it works. . .
1) you set an optimal framerate, say 35 fps
2) each loop you randomly either draw a frame or update the logic.
3) keep track of the frame rate
4) if the framerate exceeds the optimal, then slightly increase the chance of updating logic / decrease chance of rendering and vica versa
5) set limits (probably best based on a mininum # of updates per sec) so that it doesn't become impossible to render or update.
6) use delta timing in your update loop to keep movement consistant.
That way you should be able to run at near enough your optimal frame rate and update as much as is possible at that framerate with no time loss. You would also easily allow the user to adjust their optimal framerate - so a slow computer could use an optimal of say 20 fps etc and the physics would therefore not suffer, and someone with a super fast computer could run as fast as they are able to, without the loss of update accuracy.
I think I'll try this and see if it works. . .