Love2D WebPlayer (WebGL)

Discuss any ports of LÖVE to different platforms.
User avatar
tsturzl
Party member
Posts: 161
Joined: Fri Apr 08, 2011 3:24 am

Re: Love2D WebPlayer

Post by tsturzl » Wed Mar 21, 2012 12:23 am

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.

User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Love2D WebPlayer

Post by TechnoCat » Wed Mar 21, 2012 4:19 am

There appears to have been a regression: http://i.imgur.com/FUF0y.png
This is the commit that breaks it for me: https://github.com/ghoulsblade/love-web ... 7a4d282735

Did a pull request for keyboard/joystick: https://github.com/ghoulsblade/love-web ... nt-4611419

User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer

Post by ghoulsblade » Wed Mar 21, 2012 7:56 am

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.
love-android - gamejams

User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Love2D WebPlayer

Post by molul » Wed Mar 21, 2012 8:48 am

That looks awesome. I'm suscribing to this topic :)

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love2D WebPlayer

Post by Robin » Wed Mar 21, 2012 9:38 am

How about something like:

Code: Select all

... something with newImage
while image.width == 0
     do nothing
Help us help you: attach a .love.

User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Love2D WebPlayer

Post by miko » Wed Mar 21, 2012 10:56 am

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.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love2D WebPlayer

Post by Robin » Wed Mar 21, 2012 11:21 am

Hm, ok.
Help us help you: attach a .love.

User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer

Post by ghoulsblade » Wed Mar 21, 2012 11:40 am

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.
love-android - gamejams

User avatar
semihmasat
Prole
Posts: 27
Joined: Sun Mar 04, 2012 2:38 am

Re: Love2D WebPlayer

Post by semihmasat » Wed Mar 21, 2012 12:35 pm

oh this is amazing.

thank you ^^ stay with löve !
You must pay for your crimes against the earth.

User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Love2D WebPlayer

Post by TechnoCat » Wed Mar 21, 2012 2:09 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests