love-loader: load resources in a separate thread, easily

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: love-loader: load resources in a separate thread, easily

Post by bartbes »

I had to make two changes to make it work, love-loader.lua:124 still used thread:send, and in main I replaced your quit with:

Code: Select all

  if key == 'escape' then 
	  local f = love.event.quit or love.event.push
	  f("q")
  end
EDIT: Btw, love.event.quit doesn't take any arguments, but also ignores surplus ones, which is why this works. If you wonder why push("q") doesn't work any more, it's because events now have long names, so it's push("quit") instead.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: love-loader: load resources in a separate thread, easily

Post by kikito »

bartbes wrote:<Awesome feedback>
Thanks! I've updated love-loader to 1.1.0. This new version is able to load imageData and soundData, and is forward-compatible with LÖVE 0.8.x.

I'm updating the demo on the OP.
When I write def I mean function.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: love-loader: load resources in a separate thread, easily

Post by kikito »

Update: v1.1.2 fixes an error on windows. I still have to update the demo on this OP with the latest version. Will do so this evening.
When I write def I mean function.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: love-loader: load resources in a separate thread, easily

Post by Roland_Yonaba »

Nice. Guess BattleCry was updated with this new version too. Going to check.
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Re: love-loader: load resources in a separate thread, easily

Post by kexisse »

This library looks awesome. I'm thinking of using it in my project.

I create a bunch of Entities instances with images, and then set their properties based on the image size/width etc.

Currently:

Code: Select all

function Entity:initialize()
  -- load image
  -- set properties
end
With love-loader there resource isn't ready straight away, so I'm thinking about adding a single callback option to the newImage method.
So the code would look like this:

Code: Select all

function Entity:initialize()
  loader.newImage(... function()
    -- set properties
  end)
end
It's possible that draw() will get called before the image finishes loading. I'm thinking about checking self.image before drawing every time, and if it's not there, I'll draw a placeholder image. I'll be instantiating objects off-screen so hopefully the player should never see the placeholder image.

I think I know how to do this, I was just wondering if others think this is a good idea.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: love-loader: load resources in a separate thread, easily

Post by kikito »

¡Hi there!

I have already told you this (¡In person! (¡In Kyoto! How cool is that?)) but in case it helps others: I think love-loader is better-suited for implementing "an animation while loading resources". I don't think it will work for doing "dynamic loading", node.js-style, whithout heavy modifications. Nevertheless, you could use love-loader as a way to understand how threads work, and then do your own thing.

Regards!
When I write def I mean function.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: love-loader: load resources in a separate thread, easily

Post by kikito »

This Library has been ported to LÖVE 0.9.0 by the great Tanner Rogalsky. He did a great job, and left the external interface of the lib unchanged.

I am hereby releasing version 2.0.0.

I have update the OP with a demo compatible with LÖVE 0.9.0.
When I write def I mean function.
AlexYeCu
Citizen
Posts: 53
Joined: Fri May 30, 2014 4:08 pm

Re: love-loader: load resources in a separate thread, easily

Post by AlexYeCu »

Thanks for a useful library! A question: how to restart love-loader correctly?
For example:
Step 1: We are loading graphical elements and music for main menu.
Step 2: We are chainging currentState var, and one more to tell what state should be next, then making

Code: Select all

currentState.start(media, finishCallback)
by «START GAME» button pressing to load resources for a level. Bar and log show us that all resources are loaded, but next state won`t start. Guess, we need to somehow reset finish/allLoaded callback. So, how to do that?

SOLVED:

Code: Select all

currentState.start(media, loadingFinished)
Just checked everything carefully.
User avatar
murks
Party member
Posts: 185
Joined: Tue Jun 03, 2014 4:18 pm

Re: love-loader: load resources in a separate thread, easily

Post by murks »

Nice lib, I almost tried to write something like it yesterday, but eventually loaded the music as "stream" (and didn't play it using Tesound). Our game still has some loading delays but it's not as bad as with the music.
I'm sure it will come in handy for the next project though.
User avatar
georgeprosser
Citizen
Posts: 68
Joined: Fri Mar 28, 2014 5:55 pm

Re: love-loader: load resources in a separate thread, easily

Post by georgeprosser »

This is fantastic, thanks for making this and sharing it with everyone.

Just implemented a loading screen into my audio-heavy game and it immediately feels much more professional.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest