Love.js - A Direct Emscripten Port

Discuss any ports of LÖVE to different platforms.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Love.js - A Direct Emscripten Port

Post by ivan »

Great, I managed to figure out how to switch source files:

https://2dengine.com/lovejs/?g=commando.love
https://2dengine.com/lovejs/?g=arena.love
https://2dengine.com/lovejs/?g=chains.love
https://2dengine.com/lovejs/?g=collisions.love

Looks like I broke the caching feature, but I will try to get that fixed.
Attached is the latest player code. I will send a pull request once the cache is fixed.
Attachments
lovejsplayer.zip
(3.16 MiB) Downloaded 2332 times
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Love.js - A Direct Emscripten Port

Post by Davidobot »

I get the security aspect, but I don't think it's such a necessary precaution here. For example, you can just change https://github.com/Davidobot/love.js/bl ... ame.js#L29 and load the "game.data" (which is just a .love file) from any hosted url.

The majority of index.js can be cut out if you assume the passed argument is a .love file and not a folder - the file size is necessary if the passed thing is a folder.

I believe all you need to do for a portable .love file is provide the file's metadata (https://github.com/Davidobot/love.js/bl ... ex.js#L120, which is created here https://github.com/Davidobot/love.js/bl ... dex.js#L96 and used here https://github.com/Davidobot/love.js/bl ... me.js#L127 ). Alternatively, just scrap the metadata and change game.js#L127 to just read in the provided .love file with the correct file size.

EDIT: looks like you managed without my help while I was typing this up :) maybe some of these ramblings will be useful.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Love.js - A Direct Emscripten Port

Post by ivan »

Davidobot wrote: Tue Feb 02, 2021 3:38 pm I get the security aspect, but I don't think it's such a necessary precaution here. For example, you can just change https://github.com/Davidobot/love.js/bl ... ame.js#L29 and load the "game.data" (which is just a .love file) from any hosted url.
Cross domain xmlrpc requests are certainly possible, but it has caveats. For example, if the domain hosting the player uses SSL and the other domain doesn't then the request may get blocked.
I believe all you need to do for a portable .love file is provide the file's metadata (https://github.com/Davidobot/love.js/bl ... ex.js#L120, which is created here https://github.com/Davidobot/love.js/bl ... dex.js#L96 and used here https://github.com/Davidobot/love.js/bl ... me.js#L127 ). Alternatively, just scrap the metadata and change game.js#L127 to just read in the provided .love file with the correct file size.
Great, I will look into this. Any help is greatly appreciated!

PS. Yes, I managed to get the cache fixed. Basically I am getting the package size during the xmlrpc request and then storing it in the cache. My solution is hacky but I don't want to rewrite the entire game.js file. I have also added a proper useragent check and the &f=1 parameter which hides the fullscreen button.
BTW does anybody know where I can find the nogame.love file for 11.3?
So yea, it will need more work, but here is what I have so far. Next, I will think about how this the player be embedded on websites.
Attachments
lovejsplayer.zip
(3.16 MiB) Downloaded 2130 times
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Love.js - A Direct Emscripten Port

Post by Davidobot »

ivan wrote: Tue Feb 02, 2021 3:57 pm PS. Yes, I managed to get the cache fixed. Basically I am getting the package size during the xmlrpc request and then storing it in the cache. My solution is hacky but I don't want to rewrite the entire game.js file. I have also added a proper useragent check and the &f=1 parameter which hides the fullscreen button.
BTW does anybody know where I can find the nogame.love file for 11.3?
So yea, it will need more work, but here is what I have so far. Next, I will think about how this the player be embedded on websites.
Super! No solution is "hacky" if it works ;) What's the useragent check do? Also, did you manage to figure out why it sometimes gives a MIME error for wasm?

The code for nogame can be found here: https://github.com/Davidobot/love/blob/ ... nogame.lua you can just rip that and put it into a .love
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Love.js - A Direct Emscripten Port

Post by ivan »

What's the useragent check do
Checks if we are using a mobile browser in which case it goes into compatibility mode.
Also discovered navigator.deviceMemory which could be used to define and clamp the allocated memory.
Also, did you manage to figure out why it sometimes gives a MIME error for wasm?
I remember researching into this a while ago, but I can't recall the cause for this warning.

Thanks for the nogame, but I can't get it to run. I get "pthread_sigmask()" is not supported.
Also have some issues running love files using a relative path, but these are minor gripes.
Thanks so much for the help!
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Love.js - A Direct Emscripten Port

Post by Davidobot »

ivan wrote: Tue Feb 02, 2021 7:22 pm
What's the useragent check do
Checks if we are using a mobile browser in which case it goes into compatibility mode.
Also discovered navigator.deviceMemory which could be used to define and clamp the allocated memory.
Got it, thanks!
ivan wrote: Tue Feb 02, 2021 7:22 pm Thanks for the nogame, but I can't get it to run. I get "pthread_sigmask()" is not supported.
Also have some issues running love files using a relative path, but these are minor gripes.
Thanks so much for the help!
Maybe something to do with the string encoded images? I might try to get a version running when I find the time...

Thanks so much for your contributions. I early await accepting your pull requests :)
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Love.js - A Direct Emscripten Port

Post by ivan »

Maybe something to do with the string encoded images? I might try to get a version running when I find the time...
Thanks it was an oversight on my part. The nogame.love works fine with love.js.
Thanks again for the help!
gianmichele
Citizen
Posts: 67
Joined: Tue Jan 14, 2014 11:03 pm

Re: Love.js - A Direct Emscripten Port

Post by gianmichele »

I love the idea of a small executable where one could drop it’s game and generate the web version. I guess it will have to be a separate download. Definitely the right spirit!

I’m getting a loading failed on all the latest examples posted and locally as well.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Love.js - A Direct Emscripten Port

Post by ivan »

You don't need to build the web player. Just copy it on a server and it will work. It won't work locally without a server. If you are getting "loading failed" you probably need to flush your browser cache or open a new incognito window.

You need to use the g= argument to specify which love file to load:
index.html?g=mygame.love
The love file has to be in the same folder as the player until we figure this out.
Attachments
lovejsplayer.zip
(3.31 MiB) Downloaded 2057 times
gianmichele
Citizen
Posts: 67
Joined: Tue Jan 14, 2014 11:03 pm

Re: Love.js - A Direct Emscripten Port

Post by gianmichele »

yes, was testing from a local webserver. The new zip file works marvelously :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest