Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (612)
Games in Android Showcase (172)
games submitted by our members
Games in WIP (658)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Variable step timing - Good or bad?  (Read 3416 times)
0 Members and 1 Guest are viewing this topic.
Offline mrekim

Junior Newbie

« Posted 2012-02-19 22:32:44 »

I've read the Game-Loops Thread ( today and I'm curious about the var step timing regarding collision detection.
Let's say I've got a pretty decent PC, capping the fps at 60 fps and I move a primitive like this:
x = x+0.1f*delta;

Now this should run fine on most machines and it will stutter if I cap the FPS at 5 Fps.
When I now test pixel perfect collision with the 5 FPS Cap it is not possible to get the same accuracy as I get with more FPS.
Are there any tricks to solve this? Or do I need fixed step timing?

Offline ra4king

JGO Kernel

Medals: 389
Projects: 3
Exp: 5 years

I'm the King!

« Reply #1 - Posted 2012-02-19 23:34:40 »

First question is: why do you feel the need to cap at 5FPS?

Setting the game loop at 60FPS should be sufficient enough for most collision detection.

However if you still feel the need to check for those "in-between" areas, you could just create a rectangle that encompasses that area and check for collision that way.

Offline ReBirth
« Reply #2 - Posted 2012-02-20 02:41:02 »

Actually collision on low fps should work, if you store the x and y in double.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Beamery

Senior Newbie

Medals: 1

« Reply #3 - Posted 2012-02-20 04:18:17 »

The lack of accuracy is likely just due the the fact that there is more time between updates.  More time between updates means more entity movement between updates and the potential for an entity to move into and then out of collision with another entity before the game is updated. Also puzzled as to why you would want to cap the FPS at 5...
Offline Roquen
« Reply #4 - Posted 2012-02-20 07:38:24 »

Variable time steps leads to non-deterministic simulations.  Personally I consider that to be undesirable.  Using doubles doesn't (really) solve anything.
Offline mrekim

Junior Newbie

« Reply #5 - Posted 2012-02-20 08:47:42 »

I know, that no one would cap at 5 FPS - I just did for testing the collision.
Thanks for your answers yet - another possibility in for me was to calculate the optimal time like 1000ms/60 for 60FPS = ~16.
Now I sum up the delta times for every update and do the update when the sum >= 16.
But I feel like wasting resources as this would render duplicate frames without changing anything.

I will try to implement fixed step timing. Anyone ever did this within the Slick Framework?
Offline ReBirth
« Reply #6 - Posted 2012-02-21 03:58:09 »

Just add sleep...?

Offline mrekim

Junior Newbie

« Reply #7 - Posted 2012-02-21 08:54:31 »

well... Cheesy Actualy I also want to interpolate the drawings.
Offline Roquen
« Reply #8 - Posted 2012-02-21 10:11:14 »

If you want to keep it simple.  Just render and update the simulation at 60Hz and if you slow be  it.
Offline Beamery

Senior Newbie

Medals: 1

« Reply #9 - Posted 2012-02-21 15:50:27 »

If you want to keep it simple.  Just render and update the simulation at 60Hz and if you slow be  it.

This is what I've done with my game loop and it seems to work fine so far.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #10 - Posted 2012-02-23 19:42:29 »

In general it's probably a good idea to add in sweeping collision or something like that, because you will have the same problem at any FPS if you have very fast objects.

See my work:
OTC Software
Offline Roquen
« Reply #11 - Posted 2012-02-24 09:01:03 »

On the whole, it'd suggest just using a pre-exisiting physic library.  Building one from scratch is alot of work.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

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

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

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

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

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

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

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

GamerC4 (29 views)
2015-08-22 20:37:01

Kefwar (34 views)
2015-08-22 18:07:24

GamerC4 (26 views)
2015-08-22 01:00:24
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!