Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 2906 times)
0 Members and 1 Guest are viewing this topic.
Offline mrekim

Junior Newbie





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

I've read the Game-Loops Thread (http://www.java-gaming.org/topics/game-loops/24220/view.html) 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:
1  
2  
x = x+0.1f*delta;
rectangle.setX(x);


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?

Online ra4king

JGO Kernel


Medals: 342
Projects: 2
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-02-20 00: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 03: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 05: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 08: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 09: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 04:58:09 »

Just add sleep...?

Offline mrekim

Junior Newbie





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

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

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

Senior Newbie


Medals: 1



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

If you want to keep it simple.  Just render and update the simulation at 60Hz and if you slow down...so 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 20: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 10: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.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!