## 60 fps?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
hertzcastle
Party member
Posts: 100
Joined: Sun Jan 04, 2009 4:51 pm
Location: brighton, uk

### 60 fps?

hi!
im a former blitzmax user and i was wondering if there's any way of making love update at a limit of 60fps or under(if the game cant handle it). so if i wanted a tilemap to update at at least a similar speed on different machines. delta time comes in floats and even when i floor them they seem pretty unpredictable. i know the timer.sleep thing is in place, but it says in the docs that it varies from system to system. does anyone know how badly it varies? if i wanted a 60fps limit/clock, what would i have to do?
thanks!x
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: 60 fps?

I'm not sure what you want, but it appears vsync is it.. check out love.graphics.setMode.

Furthermore, you can use dt to specify speed in units/second, so if you want something to move 10 pixels every second you add 10*dt to the coordinates.
lostbuthappy
Prole
Posts: 3
Joined: Thu Oct 29, 2009 11:21 pm
Location: Germany

### Re: 60 fps?

Hi,
if I'm not mistaken 0.6.0 gives you access to the game loop and therefore allows you to implement a fixed framerate - in theory. But I wonder why you'd want that. Time based movement is the superior and more flexible technique.
Beware, I know umlauts!
hertzcastle
Party member
Posts: 100
Joined: Sun Jan 04, 2009 4:51 pm
Location: brighton, uk

### Re: 60 fps?

ah sorry, wasnt very clear with my post.
i basically want to be able to scroll without having flickering or floats. not just for tilemaps but for parallax etc.
cant seem to work out how to do it. tried floor/ciel but no joy. any ideas? is there a way to cast numbers as ints in lua?
thankyou.x
hertzcastle
Party member
Posts: 100
Joined: Sun Jan 04, 2009 4:51 pm
Location: brighton, uk

### Re: 60 fps?

ill upload a simple example of what's going wrong, just in case anyone feels like looking thru it
x
Attachments
loveGold.love.zip
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

### Re: 60 fps?

You had a logic error. I fixed it for you though. It was in function doScroll(....)

Instead of shifting the image 4 places to the right from its current position (could be less than -256) , you were putting it at a fixed location 256*4.

I changed

Code: Select all

tableScroll[i] = 256 * 4
to

Code: Select all

tableScroll[i] = tableScroll[i] + 256 * 4

Code: Select all

function load()
love.graphics.setMode(640, 480, false, true, 0)
imgBack = love.graphics.newImage("image/back1.png")
imgScrollBack = love.graphics.newImage("image/scrollLowBack.png")
imgScrollBack:setCenter(0,0)
imgScrollFront = love.graphics.newImage("image/scrollLowFront.png")
imgScrollFront:setCenter(0,0)
xScrollFront = {0*256 , 1*256, 2*256, 3*256}
xScrollBack = {0*256, 1*256, 2*256, 3*256}
end

-- Logic
function update(dt)
doScroll(xScrollBack, 256, dt)
doScroll(xScrollFront, 512, dt)
end

-- Scene Drawing
function draw()
love.graphics.draw(imgBack, 320, 240)
doDrawScroll()
end

function doScroll(tableScroll, speed, delta)
local distance = speed*delta
for i, v in ipairs(tableScroll) do
if tableScroll[i] <= -256 then
tableScroll[i] = tableScroll[i] + 256 * 4
end
tableScroll[i] = tableScroll[i] - distance
end
end

function doDrawScroll()
for i, v in ipairs(xScrollBack) do
love.graphics.draw(imgScrollBack, math.floor(xScrollBack[i]), 480 - 128)
end
for i, v in ipairs(xScrollFront) do
love.graphics.draw(imgScrollFront, math.floor(xScrollFront[i]), 480 - 128)
end
end
Prole
Posts: 30
Joined: Mon Oct 26, 2009 6:18 pm

### Re: 60 fps?

I'm assuming 0.6 is limited all the time to 60/61FPS, because no matter how much crap I spawn, (nothing or tonnes), it's 60. Until I loaded images on draw, and the ram maxed out!
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: 60 fps?

0.6.0, just as 0.5.0 uses vsync by default, which means the max FPS is your monitor refresh speed, which is 59/60 on most screens.
hertzcastle
Party member
Posts: 100
Joined: Sun Jan 04, 2009 4:51 pm
Location: brighton, uk

### Re: 60 fps?

ah wow thanks guys! good catch techno cat!
so im guessing that love updates at a max of 60fps too?
x
hertzcastle
Party member
Posts: 100
Joined: Sun Jan 04, 2009 4:51 pm
Location: brighton, uk

### Re: 60 fps?

also thanks again technocat for cleaning up my awful code!!

### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 37 guests