I'm not totally sure, but I think the problem might be on the low end computer and not in the high end one. However, I'm a Löve beginner, so you'll have to wait for someone with more knowledge to help you with this.
Sorry for not being so helpful
FPS issues in platformer
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: FPS issues in platformer
That "sophisticated way" that included update logic inside love.draw is wrong. Probably it would be better to remove it from the wiki.
When I write def I mean function.
Re: FPS issues in platformer
Back to this topic, I removed those lines I found in the wiki and everything went fine, but today I tested my project in another laptop and it runs at 70fps, and its monitor refresh rate is 60Hz, so it's not a matter of vsync (unless it's a bug).
So, what's the proper way to limit fps to a certain value? I already use dt in my update functions, by the way.
PS: the funny thing is that the computer in which the game runs faster is a low-end one (lol).
EDIT: it was a problem with Nvidia drivers. I updated to the latest version and vsync works like a charm
So, what's the proper way to limit fps to a certain value? I already use dt in my update functions, by the way.
PS: the funny thing is that the computer in which the game runs faster is a low-end one (lol).
EDIT: it was a problem with Nvidia drivers. I updated to the latest version and vsync works like a charm
Re: FPS issues in platformer
Optimally, your game shouldn't NEED vsync to work. Vsync doesn't work well on all hardware. Even my computer with an i5 @ 4*3.2 GHz becomes a sluggish slug when it tries to chomp a LÖVE game with vsync on. With proper use of dt, a platformer should work just fine even if the framerate goes crazy. Try to turn off vsync, and find out what goes wrong. A typical beginner error is to multiply by dt twice, often on different lines.
The only games that absolutely need a constant FPS on all computers are some games where split second timing is important, like a competitive fighting game. A platformer requires timing as well, but not the kind of split second accuracy we're talking about here. I'm pretty sure Super Meat Boy doesn't vsync on my computer and it runs like a dream.
The only games that absolutely need a constant FPS on all computers are some games where split second timing is important, like a competitive fighting game. A platformer requires timing as well, but not the kind of split second accuracy we're talking about here. I'm pretty sure Super Meat Boy doesn't vsync on my computer and it runs like a dream.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: FPS issues in platformer
Well if I turn vsync off, my game runs more or less at 600fps.
I'd like to do my game time-based, not frame-based as it is now. Anybody knows of a good example to start from?
I'd like to do my game time-based, not frame-based as it is now. Anybody knows of a good example to start from?
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: FPS issues in platformer
When I write def I mean function.
Re: FPS issues in platformer
I knew about its existence, but not much about its use. Is it as easy as just multiplying any movement (player, scroll, tiles) by dt?
EDIT: I think I got it. I've also remembered that in the beginning I discarded using this approach because I found the game was slower, but now I see it wasn't because it was consuming more CPU. The movements are slower, yes, but consistent. If I turn vsync on and off I see exactly the same speed in animations and movements, in 60FPS and in 600FPS, so I guess I'll see the same on < 60FPS (but it will cut some frames). Now I just need to re-adjust my code increasing the speed and acceleration values until it moves as before. Cool!
EDIT: I think I got it. I've also remembered that in the beginning I discarded using this approach because I found the game was slower, but now I see it wasn't because it was consuming more CPU. The movements are slower, yes, but consistent. If I turn vsync on and off I see exactly the same speed in animations and movements, in 60FPS and in 600FPS, so I guess I'll see the same on < 60FPS (but it will cut some frames). Now I just need to re-adjust my code increasing the speed and acceleration values until it moves as before. Cool!
Last edited by molul on Mon Feb 27, 2012 3:09 pm, edited 1 time in total.
Re: FPS issues in platformer
Yes. Here's the math behind it for evidence.
If you were to simply add your speed to your character's position every time update is called, then you are not moving at \(speed\frac{\text{pixels}}{\text{second}}\), but rather \(speed\frac{\text{pixels}}{\text{second}}*FPS\). In order to combat the \(FPS\), you need to multiply it by it's inverse, \(dt\). So \(speed\frac{\text{pixels}}{\text{second}}*FPS*dt=speed\frac{\text{pixels}}{\text{second}}*FPS*\frac{1}{FPS}=speed\frac{\text{pixels}}{\text{second}}\).
If you were to simply add your speed to your character's position every time update is called, then you are not moving at \(speed\frac{\text{pixels}}{\text{second}}\), but rather \(speed\frac{\text{pixels}}{\text{second}}*FPS\). In order to combat the \(FPS\), you need to multiply it by it's inverse, \(dt\). So \(speed\frac{\text{pixels}}{\text{second}}*FPS*dt=speed\frac{\text{pixels}}{\text{second}}*FPS*\frac{1}{FPS}=speed\frac{\text{pixels}}{\text{second}}\).
Re: FPS issues in platformer
Thanks for the explanation, I finally got it
Wow, how have I lived without using this? I hope the OP finds this helpful as well
EDIT: wow, this is being a bit tough. Having an acceleration variable complicates things a lot Well, it'll take me some time to readjust the physics.
Wow, how have I lived without using this? I hope the OP finds this helpful as well
EDIT: wow, this is being a bit tough. Having an acceleration variable complicates things a lot Well, it'll take me some time to readjust the physics.
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 6 guests