The legality of Minicraft's source is a nice conversation and all, but could we answer my question? I could have said it was from a friend and you'd have no idea it came from Minicraft, therefore its origin is irrelevant.

In your code, the main inaccuracy I see is that you divide milli_per_sec by ups then multiply by nano_milli. It would be much more efficient and would result in more accurate update if you just divide nano_sec by ups.

In Notch's code, that "shouldRender" variable looks useless because it's always true, unless he has a bug where it should be set to false at first, only to be set to true when update() is called.

I never liked Notch's loop. It is way too inaccurate due to counting by 'ticks' (unprocessed) instead of nanoseconds or milliseconds.

Ok, even at 60 FPS mine still has a "jump" every second or so it seems;

His shouldRender variable is actually useful because there are some stages of the loop where no update is necessary, therefore nothing is rendered;It is set to false at the beginning of every loop, and if the math works out a certain way, shouldRender isn't set to true;It's kind of tricky;

Anyways, I am using his loop with success for the time being;It's for a roguelike, so I don't really need interpolation;

In your code, the main inaccuracy I see is that you divide milli_per_sec by ups then multiply by nano_milli. It would be much more efficient and would result in more accurate update if you just divide nano_sec by ups.

In Notch's code, that "shouldRender" variable looks useless because it's always true, unless he has a bug where it should be set to false at first, only to be set to true when update() is called.

I never liked Notch's loop. It is way too inaccurate due to counting by 'ticks' (unprocessed) instead of nanoseconds or milliseconds.

I did what you said about changing the calculation and it fixed the problem! Wow thanks!

Setting shouldRender to false after updating just caps the game at 60 FPS. The only reason it is never set to false is because Notch forgot to change it; he kept it true to see how fast the game ran while he was coding it.

Honestly, I wouldn't use Notch's game loop from Minicraft as an example. It was created in a haste since he had a time limit of 48 hours when making Minicraft. There are plently of amazing game loop example on the forums here, just look in the "Articles and tutorials" section.

Setting shouldRender to false after updating just caps the game at 60 FPS. The only reason it is never set to false is because Notch forgot to change it; he kept it true to see how fast the game ran while he was coding it.

Honestly, I wouldn't use Notch's game loop from Minicraft as an example. It was created in a haste since he had a time limit of 48 hours when making Minicraft. There are plently of amazing game loop example on the forums here, just look in the "Articles and tutorials" section.

I have spent a week on game loops and ended up with either stuff I couldn't understand (so I will not use it until I understand it, because I'm not learning),or stuff that just either didn't work or was too complex to get working in my lack of understanding...

I think the loop here is fine and simple for what I am doing. I am fine with strict limitations as well.

That said, I do agree that his loop was made in a hurry and probably isn't that great. I've seen a lot of stuff on the web, and even own quite a few books about it... the truth is I'm still not very satisfied with what I've found. The only book that comes close is Killer Game Programming, but his end solution tries to sleep for some calculated amount of time which ends up being completely an unreliable amount of time slept.

Setting shouldRender to false after updating just caps the game at 60 FPS. The only reason it is never set to false is because Notch forgot to change it; he kept it true to see how fast the game ran while he was coding it.

Honestly, I wouldn't use Notch's game loop from Minicraft as an example. It was created in a haste since he had a time limit of 48 hours when making Minicraft. There are plently of amazing game loop example on the forums here, just look in the "Articles and tutorials" section.

...or stuff that just either didn't work or was too complex to get working in my lack of understanding...

Hey, I'm reading "MINIcraft" now, but earlier I questioned about being legal to post that, because I read "MINEcraft" (facepalm).To clarify, MINIcraft's code is open to everyone. Sorry for my previous post if I offended anyone

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