Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
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  
  Movement based on FPS  (Read 1027 times)
0 Members and 1 Guest are viewing this topic.
Offline orange451

JGO Coder


Medals: 17
Projects: 2
Exp: 4 years


Your face. Your ass. What's the difference?


« Posted 2013-11-12 21:06:13 »

I don't want to limit my game to 60 FPS, as I would rather allow the game to refresh the screen faster giving the appearance that it is more smooth. Obviously, however, this means I need to make all my objects movement account for any FPS. More fps = everything moves faster; So how would I create a "coefficient" of sorts that I can use as a multiplier to slow down movement based on fps?

How would this same thing work with gravity, and friction? Friction isn't really a multiplied effect, and I haven't gotten that far in my physics class at school.

Working on a nice FPS in lwjgl Smiley http://i.imgur.com/q4uFqBS.png
Feel free to message me if you're interested!
Offline bilznatch

Senior Devvie


Medals: 8
Projects: 2
Exp: 1 year


I'm bad, I'm bad, I'm really... really bad T_T


« Reply #1 - Posted 2013-11-12 21:14:24 »

To make a game work around your current FPS you use something called "delta".
Delta is the time between frames. There are many good game loops on this forum already, but here's an outside link:
http://www.koonsolo.com/news/dewitters-gameloop/
This is one that has been recommened before. I'm not an expert on game loops (I lock to 60 fps myself), but start with delta timing.

also for friction and gravity, you need to add velocity, and make a maximum velocity, then accelerate towards this velocity when moving, and then take velocity off at a constant rate. That's how you model friction. This effect can be ignored when falling, but you need to keep the acceleration while falling as well, as that's how gravity actually works.
Offline trollwarrior1
« Reply #2 - Posted 2013-11-12 21:18:53 »

Some say human's eye can see only 60fps. Others say more makes a difference, small, but it makes it. There is no point in doing what you're asking to. You can update your game like 120/sec but it will still look almost the same. Probably the same.

I think that the only reason you would do something like you're asking is if only your game would run extremely slow on some machines. For example, 30ups instead of 60. That would make game update 2 times slower than normal, making it 2x slower than should be. This is when you would need to introduce delta to account for that slowness. There is no point in making it look more smooth than 60 fps. 60fps is very smooth for itself.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CodeHead

JGO Knight


Medals: 41


From rags to riches...to rags.


« Reply #3 - Posted 2013-11-12 21:23:39 »

Try this thread. It covers various approaches, including Dewitter's (as mentioned by biznatch) and discusses their pros and cons. The "ideal frame rate" to shoot for in my opinion is the rate that your monitor V-syncs to. No use drawing more than can be displayed by the hardware after all.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #4 - Posted 2013-11-12 22:14:31 »

Sampling inputs as often as possible is a very good idea.

However there's little to gain from rendering more frequently than the monitor's refresh period.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #5 - Posted 2013-11-12 23:37:17 »

I wouldn't recommend doing what you're doing. What's the point? You'll just be stressing out the computer with more updates that the eye physically cannot see. If you don't know how to limit the FPS, then I recommend searching on this forum for game loops, there are plenty. You'll want to limit the FPS and then move your graphics with delta time, I.E. the time it takes to change frames. This will create the smooth movement you're talking about, whereas if you were to do it the way you want, you'll have a wildly fluxuating frame rate that will cause movement to become crazy and your objects will move at different speeds.

If you look at any game, pretty much all of them use a game loop to limit the FPS. Good ones allow you to limit the FPS to a certain rate, like mine can. Others just lock it to 60 FPS. But, like I said earlier, there is no point in rendering frames faster than the refresh rate of your monitor (generally 60 hz), and it'll just stress your CPU/GPU, which may result in poor performance compared to a game with a game loop with fixed frame rates.

Offline orange451

JGO Coder


Medals: 17
Projects: 2
Exp: 4 years


Your face. Your ass. What's the difference?


« Reply #6 - Posted 2013-11-13 01:31:35 »

Quote
If you look at any game, pretty much all of them use a game loop to limit the FPS. Good ones allow you to limit the FPS to a certain rate, like mine can. Others just lock it to 60 FPS. But, like I said earlier, there is no point in rendering frames faster than the refresh rate of your monitor (generally 60 hz), and it'll just stress your CPU/GPU, which may result in poor performance compared to a game with a game loop with fixed frame rates.
I have to disagree though... Almost every game I play by default has an uncapped FPS.

Some examples:
-Call of Duty games
-ALL sources games (tf2, l4d, l4d2, css, csgo, gmod, stanley parable, ect)
-Warframe
-Soldier Front 2
-Doom 3
-Payday 2

Working on a nice FPS in lwjgl Smiley http://i.imgur.com/q4uFqBS.png
Feel free to message me if you're interested!
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #7 - Posted 2013-11-13 02:10:15 »

I believe source games can be capped though. Call of Duty can too. Actually, come to think of it, I'm pretty sure all of those can! It might not be enabled by default, but I'm sure they all have the option.

Offline orange451

JGO Coder


Medals: 17
Projects: 2
Exp: 4 years


Your face. Your ass. What's the difference?


« Reply #8 - Posted 2013-11-13 02:18:29 »

I believe source games can be capped though. Call of Duty can too. Actually, come to think of it, I'm pretty sure all of those can! It might not be enabled by default, but I'm sure they all have the option.
Right, they do have the option Smiley
But why would they be uncapped by default?

Working on a nice FPS in lwjgl Smiley http://i.imgur.com/q4uFqBS.png
Feel free to message me if you're interested!
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #9 - Posted 2013-11-13 02:28:32 »

To be honest with you, I have no idea. It was the dev's choice to do that, not mine!

And really, why uncap it the frame rate? The only reason to leave it uncapped is to show off. "My engine can run at 505 FPS, and your's can't! Ha!". Why render the game more times than it can actually be displayed? Its just a poor choice in my mind.

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

JGO Coder


Medals: 17
Projects: 2
Exp: 4 years


Your face. Your ass. What's the difference?


« Reply #10 - Posted 2013-11-13 02:32:22 »

I guess I see your reasoning Smiley

Thanks

Working on a nice FPS in lwjgl Smiley http://i.imgur.com/q4uFqBS.png
Feel free to message me if you're interested!
Offline HeroesGraveDev

JGO Kernel


Medals: 294
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #11 - Posted 2013-11-13 04:17:43 »

I'll just chip in here with some more information.

At 24 fps, the brain sees the images as something actually moving.
You can go higher than this and make for smoother viewing, but the cap for that isn't much higher than 24, and will be well under 60.

The vast majority of monitors work at 60hz (basically 60fps).
This mean that if your game runs at 300 fps, each time the monitor refreshes, 5 renders would have taken place, 4 of which would've just been ignored and waste precious CPU time.

The other way of looking at fps is update speed, but since you're asking how to keep the update speed constant, you obviously aren't referring to this.

Offline gouessej
« Reply #12 - Posted 2013-11-13 12:22:45 »

I agree with HeroesGraveDev and opiop65. I advise you to look at this article about the persistence of vision. Uncapping the frame rate is only interesting for the benchmarks, it has no visual advantage when it goes beyond the frequency of the monitor (it won't seem smoother), it just wastes CPU/GPU time and energy. Why not capping it by default and giving the option of uncapping it? You should rather take into account the time spent between 2 frames when updating.

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.

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

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

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
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!