Performance questions

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.
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Performance questions

Post by Wombat »

Here´s my project. The .love file didn´t run so i simply zip the project folder. Please draw the project folde on your love.exe ^^
You really need to add some formatting to that.
You´re right. My code is just uncleaned^^.
Last edited by Wombat on Fri Oct 07, 2011 8:18 pm, edited 1 time in total.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Performance questions

Post by Robin »

Wombat wrote:The .love file didn´t run so i simply zip the project folder.
You probably zipped the project folder, am I right?

The way to make a .love file is not creating a .zip file from the project folder, but the from the contents of the project folder (main.lua and the gfx directory in this case).
Help us help you: attach a .love.
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Performance questions

Post by Wombat »

Yes, i already know.

But it didn´t worked when i do the main.lua in the top-level.^^
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Performance questions

Post by tentus »

Wombat wrote:Yes, i already know.

But it didn´t worked when i do the main.lua in the top-level.^^
I think its because you have some case inconsistencies. If a folder has a capital letter in it, the code has to also have a capital letter (myBlaster vs myblaster)
Kurosuke needs beta testers
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Performance questions

Post by Wombat »

I have another question: How can i generate a constant framerate in my programs?

Somenone said it´s good to use love.timer.step() others say that it´s better multiplie all counters with dt.
And i think there are a lot of other possibilities...:)

Do you know a good and testet way to make a constante framrate in .love programs?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Performance questions

Post by Robin »

Wombat wrote:How can i generate a constant framerate in my programs?
Simply put, you can't.

There are certain tricks you can use, but they are all imperfect. Instead it is a good idea to anticipate the variability of the world. This means using dt, among other things.
Help us help you: attach a .love.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Performance questions

Post by GijsB »

Wombat wrote:I have another question: How can i generate a constant framerate in my programs?

Somenone said it´s good to use love.timer.step() others say that it´s better multiplie all counters with dt.
And i think there are a lot of other possibilities...:)

Do you know a good and testet way to make a constante framrate in .love programs?
The easiest way is like :

Code: Select all

local Timer0 = 0
local SOMENUMBER = 1

function love.update(dt)
Timer0 = Timer0+dt
if Timer0 > SOMENUMBER then
--do things here
Timer0 = 0
end
end
this way you have a somewhat constant update every 1(SOMENUMBER) second :D
Last edited by GijsB on Thu Oct 06, 2011 1:44 pm, edited 1 time in total.
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Performance questions

Post by Wombat »

The easiest way is like :

Code: Select all

    local Timer0 = 0
    local SOMENUMBER = 1

    function love.load(dt)
    Timer0 = Timer0+dt
    if Timer0 > SOMENUMBER then
    --do things here
    Timer0 = 0
    end
    end


this way you have a somewhat constant update every 1(SOMENUMBER) second :D
Unfortunately this doesn´t work for me. :( But thanks for your help :)

I found a solution that works for me:

Code: Select all

function load()
fps_buffer = 0
factor = 0.01
max_frame = 60
end


function update(dt)

fps = love.timer.getFPS( )
love.timer.sleep(fps_buffer)
if fps < max_frame then
fps_buffer = fps_buffer - factor
elseif fps > max_frame then
fps_buffer = fps_buffer + factor
end

end
At first you have to wait some seconds until the framerate has the value you want. I think i have to optimize it, so you don´t have to wait until the value max_frame is like you wish.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Performance questions

Post by Robin »

Wombat wrote:Unfortunately this doesn´t work for me. :( But thanks for your help :)
He should have said love.update(dt) when he said love.load(dt).
Wombat wrote:I found a solution that works for me:
Are you using LÖVE 0.5.0?
Help us help you: attach a .love.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Performance questions

Post by GijsB »

Robin wrote:
Wombat wrote:Unfortunately this doesn´t work for me. :( But thanks for your help :)
He should have said love.update(dt) when he said love.load(dt).
Wombat wrote:I found a solution that works for me:
Are you using LÖVE 0.5.0?
thanks for clearing out my horrible mistake :)
Post Reply

Who is online

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