Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
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 107065 times)
0 Members and 3 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: 355
Projects: 3
Exp: 5 years


I'm the King!


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

Wut?

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:

https://www.youtube.com/watch?feature=player_embedded&v=v9funsyB-XM

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.

Bob

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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (70 views)
2014-11-26 15:22:04

toopeicgaming1999 (59 views)
2014-11-26 15:20:36

toopeicgaming1999 (14 views)
2014-11-26 15:20:08

SHC (27 views)
2014-11-25 12:00:59

SHC (25 views)
2014-11-25 11:53:45

Norakomi (31 views)
2014-11-25 11:26:43

Gibbo3771 (25 views)
2014-11-24 19:59:16

trollwarrior1 (38 views)
2014-11-22 12:13:56

xFryIx (77 views)
2014-11-13 12:34:49

digdugdiggy (55 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
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!