Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (307)
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 49924 times)
0 Members and 2 Guests are viewing this topic.
Offline _Scyth_

Junior Member





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

What is the interpolation used for?
Online ra4king

JGO Kernel


Medals: 292
Projects: 2


I'm the King!


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

Wut?

Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #62 - Posted 2013-01-11 20: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 16:52:19 »

Loops and Things:

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

Offline fictiongame

JGO Visitor




« Reply #64 - Posted 2013-05-20 00: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
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #65 - Posted 2013-05-23 19: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
Pages: 1 2 [3]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
mrbenebob (16 views)
2013-06-19 14:55:23

BrassApparatus (25 views)
2013-06-19 08:52:37

NegativeZero (28 views)
2013-06-19 03:31:52

NegativeZero (31 views)
2013-06-19 03:24:09

Jesse_Attard (34 views)
2013-06-18 22:03:02

HeroesGraveDev (71 views)
2013-06-15 23:35:23

Vermeer (70 views)
2013-06-14 20:08:06

davedes (72 views)
2013-06-14 16:03:55

alaslipknot (64 views)
2013-06-13 07:56:31

Roquen (88 views)
2013-06-12 04:12:32
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
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!