Love2D WebPlayer (WebGL)

Discuss any ports of LÖVE to different platforms.
chris
Prole
Posts: 17
Joined: Sat Sep 20, 2008 5:48 am

Re: Love2D WebPlayer (WebGL)

Post by chris »

Greatest project in Löves whole history!!! :)
I only hope there's much room left for optimisations, since it wouldn't be very usable with this speed..
But nevertheless:: You rock !! This may make Löve work on Facebook, Iphone, Android, Windows Phone, in the future.
User avatar
SiENcE
Party member
Posts: 806
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Love2D WebPlayer (WebGL)

Post by SiENcE »

chris wrote:Greatest project in Löves whole history!!! :)
I only hope there's much room left for optimisations, since it wouldn't be very usable with this speed..
But nevertheless:: You rock !! This may make Löve work on Facebook, Iphone, Android, Windows Phone, in the future.
This is true. Speed is a current problem, but not a future one :). All hardware is getting faster and faster and i think there is much room for coe optimization.

I hope more poeple get involved in the löve-webplayer development.
chris
Prole
Posts: 17
Joined: Sat Sep 20, 2008 5:48 am

Re: Love2D WebPlayer (WebGL)

Post by chris »

Is the lua-parser written by you, or an external library? And is it able to parse native lua functions?
User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer (WebGL)

Post by ghoulsblade »

i used an existing library : https://github.com/mherkender/lua.js
it converts the lua code to javascript at runtime and then executes it,
so you can use the webplayer for games written for normal love2d.
I'm not sure what you mean by "native lua", but you don't have to program in javascript, the webplayer runs lua code.

there are still a bunch of issues like fonts, audio in firefox, a few parser problems in some cases, some missing/not-yet-implemented api stuff (spritebatch), network and box2d... (see readme)
but as you can see it can already be used for more complex games successfully =)
love-android - gamejams
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Love2D WebPlayer (WebGL)

Post by Kingdaro »

alright, so i'm trying to use this:
falling box thing.love
(5.27 KiB) Downloaded 199 times
with the web player. when I do, it gets this error on chrome:

Code: Select all

error during love.load() : TypeError: Cannot read property 'metatable' of null : TypeError: Cannot read property 'metatable' of null
    at lua_call (http://localhost/love/js/lua-parser.js:1286:17)
    at eval at lua_load (http://localhost/love/js/lua-parser.js:35:21)
    at lua_rawcall (http://localhost/love/js/lua-parser.js:1272:17)
    at lua_call (http://localhost/love/js/lua-parser.js:1284:12)
    at call_love_callback_guarded (http://localhost/love/js/main.js:282:10)
    at call_love_load (http://localhost/love/js/main.js:339:53)
    at MainRunAfterPreloadFinished (http://localhost/love/js/main.js:521:2)
    at PreLoadImageFinishOne (http://localhost/love/js/main.js:462:2)
    at HTMLImageElement.<anonymous> (http://localhost/love/js/main.js:445:30) 
and this error on firefox:

Code: Select all

profile:102 msec: RunLuaFromPath:parse:main.lua
main.js (line 49)
error during love.load() : TypeError: func is null : lua_call(null,[object Array])<br/> @http://localhost/love/js/lua-parser.js:1286 ((void 0))<br/> @http://localhost/love/js/lua-parser.js:58 lua_rawcall((function () {var tmp;lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "setDefaultImageFilter"), ["linear", "nearest"]);lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "setPoint"), [3, "smooth"]);lua_call(G.str.require, ["extra"]);G.str.blockimg = lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "newImage"), ["img/block.png"])[0];G.str.screen = lua_newtable([], "width", lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "getWidth"), [])[0], "height", lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "getHeight"), [])[0]);G.str.field = lua_newtable([], "width", 3200);G.str.gWorld = lua_newtable();G.str.gTime = 0;G.str.gTick = lua_call(G.str.newTick, [])[0];G.str.Gravity = 700;G.str.Controls = lua_newtable([], "right", "right", "left", "left", "jump", "up", "grab", "z");G.str.JoyControls = lua_newtable([], "jump", 3, "grab", 4);lua_call(G.str.require, ["camera"]);lua_call(G.str.require, ["camerashake"]);lua_call(G.str.require, ["block"]);lua_call(G.str.require, ["player"]);G.str.startTimer = 1;return [];}),[object Array])<br/> @http://localhost/love/js/lua-parser.js:1272 lua_call((function () {var tmp;lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "setDefaultImageFilter"), ["linear", "nearest"]);lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "setPoint"), [3, "smooth"]);lua_call(G.str.require, ["extra"]);G.str.blockimg = lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "newImage"), ["img/block.png"])[0];G.str.screen = lua_newtable([], "width", lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "getWidth"), [])[0], "height", lua_call(lua_tableget(lua_tableget(G.str.love, "graphics"), "getHeight"), [])[0]);G.str.field = lua_newtable([], "width", 3200);G.str.gWorld = lua_newtable();G.str.gTime = 0;G.str.gTick = lua_call(G.str.newTick, [])[0];G.str.Gravity = 700;G.str.Controls = lua_newtable([], "right", "right", "left", "left", "jump", "up", "grab", "z");G.str.JoyControls = lua_newtable([], "jump", 3, "grab", 4);lua_call(G.str.require, ["camera"]);lua_call(G.str.require, ["camerashake"]);lua_call(G.str.require, ["block"]);lua_call(G.str.require, ["player"]);G.str.startTimer = 1;return [];}),[object Array])<br/> @http://localhost/love/js/lua-parser.js:1284 call_love_callback_guarded("load",[object Array])<br/> @http://localhost/love/js/main.js:282 call_love_load()<br/> @http://localhost/love/js/main.js:339 MainRunAfterPreloadFinished()<br/> @http://localhost/love/js/main.js:521 PreLoadImageFinishOne("img/player.png")<br/> @http://localhost/love/js/main.js:462 ([object Event])<br/> @http://localhost/love/js/main.js:445
and I'm pretty sure i did everything right, this is my filesystem arrangement:

Code: Select all

server
|-love (the webplayer's folder)
	|-box (my game's folder)
		|-main.lua and other lua files
		|-img (where my images are)
		|-index.html (with my images defined in the preloader)
	|-js
	|-style.css
	|-imgfont.png
i had the impression that the other files were optional, is it my fault or am I using something unsupported in the player?
User avatar
ghoulsblade
Party member
Posts: 111
Joined: Sun Oct 31, 2010 6:11 pm

Re: Love2D WebPlayer (WebGL)

Post by ghoulsblade »

if it runs in normal love you probably hit something unsupported / not-yet-implemented.
sadly the error-messages produced by the webplayer don't give a position,
so i'd recommend littering the code (in your case love.load) with statements like print("load01") ... print("load02") ... to narrow it down
Most browser have a "javascript console" window that can be opened to view the output.

edit : webplayer was started for 0.7.2 and doesn't support all 0.8 stuff, so "love.graphics.setDefaultImageFilter" isn't available yet.
love-android - gamejams
fireblend
Prole
Posts: 4
Joined: Mon Apr 23, 2012 9:39 pm

Re: Love2D WebPlayer (WebGL)

Post by fireblend »

So, I want to try this on my own but I'm not sure what I might be doing wrong. I cloned the git repo, but if I try to open any of the index.html files within (belonging to the examples, nothing modified by me), they seem to crash all with the same error:

Code: Select all

error during shader init:ReferenceError: gShaderCode_Fragment is not defined
Is this due to some regression introduced in a recent commit? I can see and play the examples on the OP just fine, so I'm guessing maybe a recently-implemented something broke it? Thanks in advance!
User avatar
SiENcE
Party member
Posts: 806
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Love2D WebPlayer (WebGL)

Post by SiENcE »

fireblend wrote:So, I want to try this on my own but I'm not sure what I might be doing wrong. I cloned the git repo, but if I try to open any of the index.html files within (belonging to the examples, nothing modified by me), they seem to crash all with the same error:

Code: Select all

error during shader init:ReferenceError: gShaderCode_Fragment is not defined
Is this due to some regression introduced in a recent commit? I can see and play the examples on the OP just fine, so I'm guessing maybe a recently-implemented something broke it? Thanks in advance!
:) ... you need a webserver. here is a very small webserver you should try. put the jar into the webplayer folder and start via commandline:

Code: Select all

java -jar SimpleWebServer.jar
then go into your browser and type "localhost".

et voila.
fireblend
Prole
Posts: 4
Joined: Mon Apr 23, 2012 9:39 pm

Re: Love2D WebPlayer (WebGL)

Post by fireblend »

SiENcE wrote::) ... you need a webserver. here is a very small webserver you should try. put the jar into the webplayer folder and start via commandline:

Code: Select all

java -jar SimpleWebServer.jar
then go into your browser and type "localhost".

et voila.
Thanks! My game doesn't make the player crash, but it doesn't run correctly either :P I suspect the love.draw( ) function is drawing some stuff at seemingly hyper-accelerated speeds :P I'll do a bit of debugging

Thanks anyway :)

Edit:


Haha, after looking at lua.js code, I discovered I was right; apparently lua.js's implementation of math.rad was wrong. I already submitted a pull request to the lua.js project: https://github.com/mherkender/lua.js/pull/11

In order to fix it for Love2D-webplayer, just generate the lua-parser.js file again once my commit has been cleared, or take a look at the change in code (minimal) and fix it yourself on lua-parser.js, that fixed my problem :)

You can see the web version of my game here: http://fireblend.github.com/love-web/DaH/

Cheers!
User avatar
SiENcE
Party member
Posts: 806
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Love2D WebPlayer (WebGL)

Post by SiENcE »

fireblend wrote:You can see the web version of my game here: http://fireblend.github.com/love-web/DaH/
Cheers!
Haha so cool game! Well done. It makes really fun! The monster could be more evil :).

The music is superb.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests