Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  UPS and FPS, Interpolating movement  (Read 609 times)
0 Members and 1 Guest are viewing this topic.
Offline notk0

Senior Newbie





« Posted 2013-05-30 22:20:27 »

Hello,
my game loop used to be
update
draw
paint
60 times per second
sleep till next frame
in case of oversleep skip frames, update more
....
It used to be smoother

now I have read that the proper way to do it is to lock UPS and do as much FPS as possible while interpolating movement
I decided to limit fps to 60 since there is no point to have more anyway, ( screen refresh rate, etc)

Now my game feels sluggish and unresponsibe
what can I do?
Offline relminator
« Reply #1 - Posted 2013-05-31 09:33:58 »

Code?

Using sleep to limit frames is not generally a good idea.  At least that's what most people say here.

Use sleep so that your app doesn't hog resources.

With interpolation, you need to save the old positions of all your entities and interpolate between the old and the new positions based on normalized dt (0 to 1).

This article might be of use:

http://games.freebasic.net/BASICGaming/Issue9/index.html#tutorial1


Offline notk0

Senior Newbie





« Reply #2 - Posted 2013-05-31 17:58:14 »

Code?

Using sleep to limit frames is not generally a good idea.  At least that's what most people say here.

Use sleep so that your app doesn't hog resources.

With interpolation, you need to save the old positions of all your entities and interpolate between the old and the new positions based on normalized dt (0 to 1).

This article might be of use:

http://games.freebasic.net/BASICGaming/Issue9/index.html#tutorial1



I think the issue is that since I reduced the number of UPS from 60 to 30 the game behaves differently, even IF I change the values.
well I have to sleep to not hog resourced, But when should I sleep?
I usually sleep till the next update or render ( whichever is sooner)

I modified my moveable interface into an abstract class and made it that if you set X/Y or do MoveX/MoveY it automatically saves the previous
as well as doing lerp and stuff
It works rather good, at least movement isn't worse than before but still not optimal, I will try to provide 2 versions, unfortunately I didn't use a version control system, so I don't have older code, stupid of me I know...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline notk0

Senior Newbie





« Reply #3 - Posted 2013-06-02 10:23:59 »

Code?

Using sleep to limit frames is not generally a good idea.  At least that's what most people say here.

Use sleep so that your app doesn't hog resources.

With interpolation, you need to save the old positions of all your entities and interpolate between the old and the new positions based on normalized dt (0 to 1).

This article might be of use:

http://games.freebasic.net/BASICGaming/Issue9/index.html#tutorial1




I have read that article, I thought interpolation was using during rendering not during updating?
I didn't quite understand some things from that article. he claims you can use dt in fixed dt loop, but that is the way it is usually done
the alternative is to not pass a dt since it is considered constant.
Offline relminator
« Reply #4 - Posted 2013-06-02 12:56:05 »

The idea is to have a dt-based gameloop that updates at 60fps thereby allowing you to code in a framebased manner.

If you tried to run the examples, you'll notice that the last part has a demo of all the 4 systems running simultaneously.

I've used the last type on my latest game.  The caveat is that you can't do interpolation.

Speaking of which, you interpolate during logic, store that value in a variable and use it come rendertime.

Btw, I wrote that article.
Offline notk0

Senior Newbie





« Reply #5 - Posted 2013-06-02 15:44:32 »

The idea is to have a dt-based gameloop that updates at 60fps thereby allowing you to code in a framebased manner.

If you tried to run the examples, you'll notice that the last part has a demo of all the 4 systems running simultaneously.

I've used the last type on my latest game.  The caveat is that you can't do interpolation.

Speaking of which, you interpolate during logic, store that value in a variable and use it come rendertime.

Btw, I wrote that article.

during logic you store previous x/y? and during rendering you interpolate between them no?
I still don't understand a dt-based gameloop .. allowing to code in a framebased manner.
if you update at regular intervals you have a fixed dt so it's not frame based? am I missing something? (it's frame based if you do exactly one render for each update and don't interpolate I guesS)
Offline relminator
« Reply #6 - Posted 2013-06-02 16:41:41 »

The examples in the article has sources.  You might wanna try to read them.

Here it is in java:

www.java-gaming.org/topics/basic-2d-tile-collision/29657/view.html

Note that it uses java2d so depending on your setup, things might get a little jittery.
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.

BurntPizza (15 views)
2014-09-19 03:14:18

Dwinin (33 views)
2014-09-12 09:08:26

Norakomi (58 views)
2014-09-10 13:57:51

TehJavaDev (81 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (63 views)
2014-09-08 06:06:29

BurntPizza (46 views)
2014-09-07 01:13:42

Longarmx (33 views)
2014-09-07 01:12:14

Longarmx (38 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
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

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

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!