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
Post
by Wombat » Mon Oct 03, 2011 9:15 pm
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
kraftman
Party member
Posts: 277 Joined: Sat May 14, 2011 10:18 am
Post
by kraftman » Mon Oct 03, 2011 9:23 pm
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
Post
by Wombat » Mon Oct 03, 2011 9:34 pm
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?
kraftman
Party member
Posts: 277 Joined: Sat May 14, 2011 10:18 am
Post
by kraftman » Mon Oct 03, 2011 9:39 pm
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
Post
by Wombat » Mon Oct 03, 2011 9:50 pm
Sorry but that´s realy too much code^^.
Is it possible to run code without the 3 callback functions?
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Mon Oct 03, 2011 9:58 pm
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).
kraftman
Party member
Posts: 277 Joined: Sat May 14, 2011 10:18 am
Post
by kraftman » Mon Oct 03, 2011 10:09 pm
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
Ensayia
Party member
Posts: 399 Joined: Sat Jun 12, 2010 7:57 pm
Post
by Ensayia » Mon Oct 03, 2011 10:51 pm
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.
kikito
Inner party member
Posts: 3153 Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:
Post
by kikito » Tue Oct 04, 2011 7:52 am
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 .
T-Bone
Inner party member
Posts: 1492 Joined: Thu Jun 09, 2011 9:03 am
Post
by T-Bone » Tue Oct 04, 2011 9:08 am
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).
Users browsing this forum: Ahrefs [Bot] , Bing [Bot] and 4 guests