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

Performance questions

Post by Wombat »

Hi there,

i am new in working with LÖVE. But i work with LUA since 4 years.

I wanted to edit a game i made with another Lua-wrapper to run it on LÖVE.

But unfortunately it runs very very slow :(.

It would be too much code if i would post it here. But here is the structure how i made it:

Code: Select all

love.load()
--all the things to load

love.update(dt)
love.draw()

--all the code

end
end

Maybe the problem exist, ´cause of i do the love.draw() in the love.update(dt).


Furthermore the whole framerate goes even more down when i want to scale my game to fullscreen.


Do you have any performance tips for me? :)


Thanks in advance ^^
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Performance questions

Post by kraftman »

Essentially what you are doing there is redefining the love.draw function and everything in your game multiple times per second.

love.draw and love.update need to be seperate, keep most of your game code out of them, and only use them for either updating or drawing. For example:

Code: Select all

function love.load()
--create an image here and set its initial position
end

function love.update(dt)
--modify the images position using dt
end

function love.draw()
--draw the image here
end
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Performance questions

Post by Wombat »

Thanks for your very fast help :).

I did it like you said, but it doesn´t work: The screen is black!!! :(

Is it neccessary to seperate love.update() and love.draw() for better performance?
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Performance questions

Post by kraftman »

well they are different things, and they should only be defined once in your code. If you can link your project I'll check out your code for you.
Wombat
Prole
Posts: 31
Joined: Mon Oct 03, 2011 8:38 pm

Re: Performance questions

Post by Wombat »

Sorry but that´s realy too much code^^.

Is it possible to run code without the 3 callback functions?
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 »

If the screen is black, it most likely is because you aren't drawing anything.
Wombat wrote:Is it possible to run code without the 3 callback functions?
Yes, but it's not going to be very useful if you don't use them.

We can only really help you if you show us our code (preferably in .love form).
Help us help you: attach a .love.
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Performance questions

Post by kraftman »

Wombat wrote:Sorry but that´s realy too much code^^.

Is it possible to run code without the 3 callback functions?
just zip it and attach it :P
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Performance questions

Post by Ensayia »

You're likely going to have to rewrite code to fit LOVE's structure. You can't expect to simply plop code in a file and run it without any modification at all. You need to make sure your game uses all the proper LOVE functions and callbacks to work correctly.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Performance questions

Post by kikito »

From the sound of it, the problem is not likely to be on the callbacks, but somewhere else.

Redefining one function continuously, while not ideal and totally not recommended, shouldn't have a huge impact.

I'd recommend stepping back, forgetting momentaneously about the callbacks, and whatching the whole picture.

... and putting the code up somewhere so we can see it. Zip makes wonders with text files.
When I write def I mean function.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Performance questions

Post by T-Bone »

We need code, yes.

If you see nothing but blackness, you're probably not drawing anything. Drawing operations has to be made inside of love.draw(), otherwise they don't do anything. If your code has drawing and updating mixed together, then placing all of it in love.draw() will at very least work (but be slow).
Post Reply

Who is online

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