Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: 1 2 [3]
  ignore  |  Print  
  Game loops!  (Read 141125 times)
0 Members and 2 Guests are viewing this topic.
Offline _Scyth_

Junior Devvie

« Reply #60 - Posted 2013-01-09 17:22:22 »

What is the interpolation used for?
Offline ra4king

JGO Kernel

Medals: 389
Projects: 3
Exp: 5 years

I'm the King!

« Reply #61 - Posted 2013-01-09 21:34:28 »


Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #62 - Posted 2013-01-11 19:35:07 »

Post that again when you're not the top of the page. Smiley

It's used for having fluidness beyond the speed of either your logic or frame updates. Generally, your FPS is going to be quite variable, so you need to calculate exactly how much you want to move things based on how fast or slow the last update was. In variable timestep, you need to interpolate the logic because it is able to run at any speed. In the case of a fixed timestep, you need to interpolate the drawing, because the logic is locked into a certain speed but the drawing is not.

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Damocles
« Reply #63 - Posted 2013-02-26 15:52:19 »

Loops and Things:

Offline fictiongame

Innocent Bystander

« Reply #64 - Posted 2013-05-19 22:48:50 »

Like the article and the thread very much, because this is what I have been looking for.
I am a newbie in game development.
From the beginning, I had questions about loop: I was wondering how accurate it would be, and what will happen if one loop is delayed, and how to synchronize between different computers.

Anyway, here is some of my questions:
(1) It seems sleep and timer is not recommended due to their low accuracy. But they do not cost CPU, right?
In "Fixed timestep" example code of the first post, it seems it uses while loop comparing the current time to the desired time point. It is time consuming, but it is claimed by OP that it is more accurate.

Is my above understanding correct?

(2) Regarding OP's "Fixed timestep",

Update is irrelated to the variable time. So what matters is the times of updates.
But render is designed to be dependent on lastUpdateTime.
I do not understand why. I mean, it seems not make sense here.

Thanks again for OP's article!
Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #65 - Posted 2013-05-23 17:59:48 »

Hey there. Glad this has been helpful for you.

1) Yeah, sleep can go wonky on some systems. If you don't use it, then your loop is going to max out your CPU, if you do then your CPU usage will only be what you need but on certain systems your frame rate will fluctuate a lot (older Windows mostly, I think). You could always include an option on which to do (for laptop users it really sucks to max the processor, your battery use goes haywire). Timer is just not the best way to do things, it specifically says its accuracy cannot be guaranteed. Would be fine for non-gamey things, though.

2) Fixed timestep is not "more accurate" than variable timestep. You should do whatever works for you. Or even just do both. Fixed timestep is very useful for stuff like physics simulations and networked games because you know everything is updating at specific intervals. Variable timestep can result in a smoother experience for very high frame rates and doesn't give you a frame of latency like fixed timestep. Neither is more accurate or more processor intensive.

In fixed timestep, your update loop is supposed to happen at even intervals every single time. This normally would force your renders to happen at exactly the same times as the updates. That means you're updating way too much or your FPS is way too low, generally. By making the renders variable (and one frame behind), you can update to any FPS with no issues, and still keep your fixed timestep.

See my work:
OTC Software
Offline Bob Strawn

Senior Newbie

Medals: 2

« Reply #66 - Posted 2013-06-21 22:15:28 »

Thank you, Eli!

This entire discussion has resolved quite a few of my timing  issues.   What I have been using for a loop trusted sleep time, which has caused me to personally lose sleep time more than once.     

Ironically, the fixed timestep version listed has the potential to leave a copy of gameLoop() running.    If you have a menu system start the Loop Test Demo for example and the user starts it and then closes the frame by X-ing out of the window, the loop will still be running despite the lack of visual update.  The thread started has no dependency or test related to the closure of the panel.


Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #67 - Posted 2013-06-28 17:53:25 »

Good point about that. I usually don't put window listeners into my games because I'm a lazy Mac OS user and don't expect closed windows to quit anything. You're right it should definitely be there in this case.

See my work:
OTC Software
Pages: 1 2 [3]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Coldstream24 (18 views)
2015-09-03 00:41:28

Andrew_3ds (29 views)
2015-09-01 19:08:10

afikri (20 views)
2015-08-31 09:30:22

afikri (26 views)
2015-08-31 09:30:07

afikri (14 views)
2015-08-31 09:27:24

afikri (17 views)
2015-08-31 09:26:40

Roquen (30 views)
2015-08-29 11:30:54

GamerC4 (38 views)
2015-08-22 20:38:50

GamerC4 (36 views)
2015-08-22 20:37:18

GamerC4 (42 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!