Hi everyone!
I was fiddling around with my first project and noticed some slow-downs and a delay when starting the game. It most likely comes from loading the music, fonts etc. so I guessed it would be neat to use threads... the problem is, I have no idea how they work. I tried to understand examples and search the forum but I really didn't find anything useful.
I noticed that the "Default Example" when starting up Love is just snapping up, no load times at all, and it seems pretty heavy. I'd like to view the source code, I dug aroung the Application but I didn't find the LUA Source. Anyone knows where I can get it?
On a short side-note: I noticed "flickers" when playing music in Love, anyone knows why Love does this? And more importantly, how to fix it? (btw, I'm using the newest Love-Version on Mac OS X 10.6.7)
So, thanks in advance.
-Cylog
Love Game Slave Example Source & Performance
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: Love Game Slave Example Source & Performance
Post your code and we can see if you're doing something wrong. If you're loading a lot of resources at once in love.load, there can be some startup time, but usually not more than a second or two.
As for the music, are you by any chance using mp3? If so, try ogg/vorbis instead. That's the preferred audio format.
As for the music, are you by any chance using mp3? If so, try ogg/vorbis instead. That's the preferred audio format.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Love Game Slave Example Source & Performance
This is pretty old and I'm guessing it still applies: http://love2d.org/forums/viewtopic.php?f=4&t=2138Cylog wrote:so I guessed it would be neat to use threads... the problem is, I have no idea how they work. I tried to understand examples and search the forum but I really didn't find anything useful.
https://bitbucket.org/rude/love/src/104 ... lua#cl-647Cylog wrote:I noticed that the "Default Example" when starting up Love is just snapping up, no load times at all, and it seems pretty heavy. I'd like to view the source code, I dug aroung the Application but I didn't find the LUA Source. Anyone knows where I can get it?
Re: Love Game Slave Example Source & Performance
Oh sweet, thanks for the fast reply nevon, TechnoCat. I didn't notice that thread, thanks.
Hm, funny, the Game Slave Demo isn't using Images per se, it seems that it decodes base64 files which are turned into ImageData. Weird. And it's not even using Threads... this should be somewhat inefficient, yet it works so well.
Thanks for the tipp with Ogg/Vorbis, it loads faster now There are still some "clicks" and flickers, but they seem rare now. I think it'd be better to play the music in a seperate thread, maybe it's interfering with the update() or other functions.
I'll inform you guys if I still encounter problems, thanks a lot
Hm, funny, the Game Slave Demo isn't using Images per se, it seems that it decodes base64 files which are turned into ImageData. Weird. And it's not even using Threads... this should be somewhat inefficient, yet it works so well.
Thanks for the tipp with Ogg/Vorbis, it loads faster now There are still some "clicks" and flickers, but they seem rare now. I think it'd be better to play the music in a seperate thread, maybe it's interfering with the update() or other functions.
I'll inform you guys if I still encounter problems, thanks a lot
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Love Game Slave Example Source & Performance
Correct, the images are inside of the binaries. (ImageData is nothing more than a decoded image.)Cylog wrote:it seems that it decodes base64 files which are turned into ImageData.
Because it loads, what? 10 small images? That shouldn't take long. Also, disk i/o.Cylog wrote:And it's not even using Threads...
Music playback is done in a separate thread by the engine.Cylog wrote:I think it'd be better to play the music in a seperate thread, maybe it's interfering with the update() or other functions.
Re: Love Game Slave Example Source & Performance
True, true, didn't think of that. Oh the performance problem makes more sense now. I'm loading a "giant" 1162 × 688 picture on start, so I guess that is the main problem. It probably would be faster to cut it into smaller pieces and load them as the game progresses...bartbes wrote:Because it loads, what? 10 small images? That shouldn't take long. Also, disk i/o.
About music playback... you're totally right I somehow thought that it'd be the programmers choice to get it into threads and stuff, I guess proper music support is only possible by multi-treading.
I tried to include threads into my game anyways, it seems though, that they don't really want to communicate with each other (I mean main() and the thread). I'll post the source here when I wake up, see ya til then
Re: Love Game Slave Example Source & Performance
Be aware that your images will need to be sized to a power of two in each dimension to work properly on all systems (8, 16, 32, 64, 128, 256, 512, etc...)Cylog wrote:I'm loading a "giant" 1162 × 688 picture...
See the wiki article on PO2 Syndrome for more details.
Re: Love Game Slave Example Source & Performance
I heard about that, thanks for reminding me anyways My game is still in a prototype phase, the image will be cut down to proper dimensions later on.Ensayia wrote:Be aware that your images will need to be sized to a power of two in each dimension to work properly on all systems (8, 16, 32, 64, 128, 256, 512, etc...)
Alright, I tried to use Threads to send a simple messages back and forth between the Thread and main, but they don't seem to respond or even recieve messages. I'm calling routines.lua from main.lua, it contains most of the code, variables are stored in a seperate file.
main.lua:
Code: Select all
function love.load()
exspark()
extload()
end
Code: Select all
function exspark()
musicload = love.thread.newThread("musix", "musicload.lua")
musicload:start()
end
function extload()
love.graphics.setBackgroundColor(0,0,0)
end
function eventtimer(dt)
time = time + (timerspeed * dt)
--EVENT 1
if time >= 1500 then
layerdecayactive = true
end
--EVENT 2
if time >= 1400 then
--Thread Message
musicload:send("ping", true)
--Thread Response
response = musicload:receive("response")
if (response) then -- if communication is working change BackgroundColor to show visible result.
love.graphics.setBackgroundColor(255,255,255)
end
end
end
function extupdate(dt)
eventtimer(dt)
end
Code: Select all
local this_thread = love.thread.getThread()
local msg = this_thread:receive("ping")
while (true) do
if (msg) then
this_thread:send("response", true)
end
end
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Love Game Slave Example Source & Performance
You never call expupdate.
Re: Love Game Slave Example Source & Performance
Oh, sorry I forgot to include that. Anyways, I'll just upload the whole .love file. As for the art... it's just a sketch and quickly colored to get a quick impression
Well, there you go. main.lua calls the function exospark() from routines.lua. routines. exospark() creates the thread. The function eventtimer(dt) tries to communicate with the thread.
You can move the picture via arrowkeys, I'm positioning and cutting it later.
The upload attachement isn't working at the moment (at least for me), so I uploaded it to my Dropbox:
http://dl.dropbox.com/u/1185194/show.love
Well, there you go. main.lua calls the function exospark() from routines.lua. routines. exospark() creates the thread. The function eventtimer(dt) tries to communicate with the thread.
You can move the picture via arrowkeys, I'm positioning and cutting it later.
The upload attachement isn't working at the moment (at least for me), so I uploaded it to my Dropbox:
http://dl.dropbox.com/u/1185194/show.love
Who is online
Users browsing this forum: Google [Bot] and 1 guest