Page 1 of 3
Loading screens...
Posted: Mon Aug 23, 2010 8:09 pm
by Chief
Since LUA runs in one "lane" I've been stumbling over some problems with drawing a loading screen at the same time that the game is loading new resources. Anyone have any ideas to get around this? Maybe threading?
Re: Loading screens...
Posted: Mon Aug 23, 2010 8:17 pm
by Tesselode
How about putting something in the update callback like this:
Code: Select all
if screen then
screen="load"
--load resources
else
screen="loading_screen"
end
And then in the draw callback have something like:
Code: Select all
if screen="loading_screen" then
--draw loading message
end
That way the game should get a chance to draw a loading message before it starts loading.
Re: Loading screens...
Posted: Mon Aug 23, 2010 8:27 pm
by Chief
Hmmyes, i catch your drift. Might just wanna stop the loading a little bit to make a breathing space for the draw function to run. Imma' try that!
Re: Loading screens...
Posted: Mon Aug 23, 2010 8:38 pm
by vrld
Use
coroutines, which are basically lightweight threads.
loader pseudocode:
Code: Select all
loader = coroutine.create(function()
for type, source in pairs(resources_to_load) do
load_resource(type, source)
coroutine.yield()
end
end)
love.update:
Code: Select all
coroutine.resume(loader)
if coroutine.status(loader) == "dead" then
-- loading finished
end
Re: Loading screens...
Posted: Mon Aug 23, 2010 10:13 pm
by Chief
I went for the coroutines, and it worked perfectly!
Until i noticed something strange! The bodies and shapes (physics) doesn't seem to be working properly (gives error) when colliding with props made outside of the coroutine.
The error is basically that it returns
"attempt to call a number value" in the physics world update...
Gotta look into this more, if no one else got a theory on how to fix this of course
Re: Loading screens...
Posted: Tue Aug 24, 2010 1:03 am
by bmelts
Full-fledged love.thread is coming in 0.7.0.
Re: Loading screens...
Posted: Tue Aug 24, 2010 2:31 am
by Luiji
Funnu thing, I was just going to ask about this.
anjo wrote:Full-fledged love.thread is coming in 0.7.0.
I can't wait!
Re: Loading screens...
Posted: Tue Aug 24, 2010 3:57 pm
by Chief
anjo wrote:Full-fledged love.thread is coming in 0.7.0.
And when is that if I may ask?
Re: Loading screens...
Posted: Tue Aug 24, 2010 4:16 pm
by nevon
Chief wrote:anjo wrote:Full-fledged love.thread is coming in 0.7.0.
And when is that if I may ask?
Around the same time as the audio issues are solved.
Re: Loading screens...
Posted: Tue Aug 24, 2010 4:41 pm
by bartbes
With the difference that love.thread already exists.