How can i set FPS?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
NoreoAlles
Party member
Posts: 107
Joined: Mon Jan 03, 2022 5:42 pm

How can i set FPS?

Post by NoreoAlles »

I need to be able to set what fps my programm will try to stay on, how would i do that?
Cheers :ultrahappy:
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
User avatar
BrotSagtMist
Party member
Posts: 607
Joined: Fri Aug 06, 2021 10:30 pm

Re: How can i set FPS?

Post by BrotSagtMist »

In a short answer: just put a sleep in every frame. This already exists in the love.run main loop. You should read about that in the wiki, its vital for such task.
In the long answer: Usually you have vsync enabled which syncs your love frame calls with your monitors refresh rate.
You can increase the vsync number in in conf.lua to get a framskip, vsync 2 at a 100hz monitor will result in 50fps for example.
But if you want this to be set freely and accurate you need to turn vsync of, calculate the delta time your program took, and then fill this number up with a sleep.
obey
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How can i set FPS?

Post by zorg »

alternatively, and this might be the more sane thing to do:
separate rendering (frame) rate from logic (tick) rate, keep framerate synced to vsync, and simply just edit a value that you restrict the logic to.

Here's a link to where you can read more on this: https://gafferongames.com/post/fix_your_timestep/
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 49 guests