I have a new issue with the fixed timestep, it seems that for alot of computers the game is very choppy (game herz 30 with 60 fps)...This happens on my desktop very rarely and I have a hard time finding the fix, anyone knowing about this?

I'm not sure if this is the failure in question...but I know that one problem early versions had was that the programmer didn't understand that 1/10 of a second (the logic rate it ran at) isn't a representable number.

Nope, Danny, I think you're wrong. You're not keeping a running total added, you're keeping a total that is refreshed multiple times per second. So any lost precision is going to be completely impossible to notice. If you were adding the time every single frame to store the game time or something, I could see that being an issue. But in this case, no.

For now i didn't have any problems, but i really don't know if my solution is the correct one, and if it affects the logic behind the variable timestep loop. Maybe someone could tell me if i'm doing something stupid...

I don't think so. You're trying to wait for 10ms, and if the last loop time was slower than that you wait for less time. See Kev explain below.

From Kev's (since update) tutorial:

Quote

To do this we're going to want each cycle round the game loop to take exactly 10 milliseconds. We know at what time the cycle started (lastLoopTime) and we know what time it is now, so with a small amount of maths we can sleep for the right amount of time like this:

1 2 3 4 5

// we want each frame to take 10 milliseconds, to do this// we've recorded when we started the frame. We add 10 milliseconds// to this and then factor in the current time to give // us our final value to wait forSystemTimer.sleep(lastLoopTime+10-SystemTimer.getTime());

Note: GAGE Timer actually supports a "sleepUntil()" method that could be used here. However, since the SystemTimer is trying to allow us to change between timing mechanisms we should try to rely on simply sleeping for the right amount of time.

The only difference is the division, that's because we're using nanoTime here and Kev is only using ms.

I can't believe your "bad" examples, I actually see people using them in full games as well. You'd think that with all the information out there which says "don't do it" or the throttling of your CPU would be enough. lol

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org