Setting the Frame rate

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.
User avatar
omegazion
Prole
Posts: 8
Joined: Sat Jan 08, 2011 3:33 pm

Setting the Frame rate

Post by omegazion »

Hello, I have just recently found Löve engine and I think i'm starting to löve it!

The previous engine I worked with I was used to having constant FPS throughout the execution. I was wondering if it can also be achieved in Löve. Is it possible to set the Frame Rate of Löve to some constant number? I've searched the wiki and all I saw was love.timer.getFPS (no set), there was also nothing about it on the configuration file.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Setting the Frame rate

Post by tentus »

You may want to read this thread: http://love2d.org/forums/viewtopic.php?f=3&t=1708
Last edited by tentus on Tue Jan 11, 2011 6:33 pm, edited 1 time in total.
Kurosuke needs beta testers
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Setting the Frame rate

Post by thelinx »

Strictly speaking, no.

Instead, you should program your game to be speed independent. Make good use of the dt variable passed to love.update.

Instead of:

Code: Select all

function love.update()
  -- hoping for 30 FPS
  moveThing(3.333) -- move it 100 pixels a second (100/30)
end
do this

Code: Select all

function love.update(dt)
  -- time independent code, yay!
  moveThing(100*dt) -- move it 100 pixels a second. this works because dt is the time since the last update, in seconds.
end
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Setting the Frame rate

Post by Robin »

Also, you can control the framerate *somewhat* by using love.timer.sleep().
Help us help you: attach a .love.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Setting the Frame rate

Post by Taehl »

When you use love.graphics.setMode to set your screen metrics, you can enable vsynch, which will cap the framerate at 60.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Setting the Frame rate

Post by TechnoCat »

Taehl wrote:When you use love.graphics.setMode to set your screen metrics, you can enable vsynch, which will cap the framerate at 60.
Doesn't work on my computer.
User avatar
omegazion
Prole
Posts: 8
Joined: Sat Jan 08, 2011 3:33 pm

Re: Setting the Frame rate

Post by omegazion »

Thanks for the really quick responses guys. I am trying to build some sort of RPG game so I don't think I need the accuracy the update per dt provides. I'll just try to do a workaround using love.timer.sleep.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Setting the Frame rate

Post by Robin »

omegazion wrote:I don't think I need the accuracy the update per dt provides
Using dt is probably still a good idea, because if you don't, the game runs much faster on a faster computer.
Help us help you: attach a .love.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Setting the Frame rate

Post by tentus »

DT should still become a vital part of your game code. For example, how fast can the player walk? How often do random encounters occur? The easiest and simplest solution is to use dt. Trust us, once your get to know it you'll wonder how you got by without it.
Kurosuke needs beta testers
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Setting the Frame rate

Post by Jasoco »

omegazion wrote:Thanks for the really quick responses guys. I am trying to build some sort of RPG game so I don't think I need the accuracy the update per dt provides. I'll just try to do a workaround using love.timer.sleep.
No, you should still use it. Seeing as you'll want your characters to walk from tile to tile, not just jump to each tile without animation. Because that's the lazy person's way out.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], slime and 8 guests