Page 4 of 21
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 12:23 am
by tsturzl
ghoulsblade wrote:new vid : in your face city trains starting to work =) (press "MainButton" at bottom of screen since we have no keyboard input yet, jumping doesn't work yet due to missing love.keyboard.isDown)
require and love.filesystem.dofile work now,
also love.graphics.newQuad and .drawq
text still missing.
try for yourself :
http://ghoulsblade.schattenkind.net/lov ... yer/iyfct/
I read an article mentioning something about how keyboard input in Chrome requires a work around. I'm not sure but I believe it was a post on the CraftyJS Blog.
Maybe you could look at the source of
https://github.com/marquete/kibo
I think you can actually use Kibo in Love2D WebPlayer, it's licensed under the MIT license.
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 4:19 am
by TechnoCat
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 7:56 am
by ghoulsblade
regression "fixed" by workaround, you might get an alert at first complete load since javascript doesn't seem to support non-browser-freezing sleep() =(
background : image loading is asynchronous with callback on complete.
Assume there is lua code that calls image:getHeight() or getWidth() directly after love.graphics.newImage(path).
This would lead to incorrect results, e.g. wrongly initialized global vars with 0 when the image isn't loaded yet at that point.
Searching for javascript sleep() on the internets only yielded potentially browser-freezing busy loops or hacks with java/flash/serverside-php-sleep etc.
SetTimeout() won't work since it cannot block code that is already running, and we cannot restructure lua code dynamically during the call either.
Busy waiting loop freezes my firefox, so not acceptable either.
For now i used "alert" which does block code successfully, but displays a message, luckily this only happens if waiting is actually needed, so as long as you don't force-reload already loaded images with CTRL+f5 or similar, you won't see it more than once.
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 8:48 am
by molul
That looks awesome. I'm suscribing to this topic
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 9:38 am
by Robin
How about something like:
Code: Select all
... something with newImage
while image.width == 0
do nothing
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 10:56 am
by miko
Robin wrote:How about something like:
Code: Select all
... something with newImage
while image.width == 0
do nothing
It was already answered:
ghoulsblade wrote:
Busy waiting loop freezes my firefox, so not acceptable either.
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 11:21 am
by Robin
Hm, ok.
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 11:40 am
by ghoulsblade
one solution might be to require a pre-load list in index.html where all graphics files are declared, then i can wait with running love.load()(and main.lua) until they are all loaded via calllback.
might be needed as even the alert box doesn't seem to fix the problem in chrome..
the core problem is the following codeblock in lua (love.load) cannot be allowed to fail when the file isn't loaded yet without changing game behavior,
and we cannot restructure lua-code at js runtime to use callbacks like setTimeout
Code: Select all
gMyImage = love.graphics.load("myimg.png");
gMyImageW = gMyImage:getWidth()
assert(gMyImageW != 0);
if all graphics used had to be declared in index.html like LovePreloadImage(["myimg.png","myimg2.png","player.png","enemy.png"]); somewhere, we could delay the execution of main.lua until all the loading has completed.
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 12:35 pm
by semihmasat
oh this is amazing.
thank you
stay with löve !
Re: Love2D WebPlayer
Posted: Wed Mar 21, 2012 2:09 pm
by TechnoCat
why can't we make image loading a blocking call? just because it temporarily freezes the browser? it would temporarily freeze love too I'm pretty sure.