morew4rd / morew4rd.com

morew4rd.com
1 stars 0 forks source link

REPL with lyte in html5 and possibility of single file html5 games? (Enhancement) #2

Open SugarRayLua opened 1 year ago

SugarRayLua commented 1 year ago

Hi. I really like the Lyte2D lua scripted game engine you are creating and that you've created an html option which makes your engine able to be more universal.

If it is not already, would you consider implementing REPL functionality in the html version of Lyte2D? I a novice mobile programmer (iOS) and prefer to do all my programming on my mobile device. I use the Textastic app on my mobile device as my text editor which also has the ability to statically locally host files so that I can run Lyte2D files that I create. However, it would be even handier to have a Lyte2D REPL environment in the html5 environment so I could do live coding with Lyte 2D.

Also, if it is not currently possible, would you consider implementing an option in Lyte2D to generate an all-in-one embedded game.html with lyte.wasm embedded? The Love2D web-builder has such an option which allows an Love2D game I create to be packaged and distributed as a single file that others can download and run directly on their devices instead of needing to host the game I create on a server.

Thanks for the consideration and creating Lyte 2D! :-)

morew4rd commented 1 year ago

Hello, thank you for your kind words!

Just FYI, I have the Lyte2D repo here: https://github.com/morew4rd/lyte2d so going forward, please file issues there directly :)

I'm actually thinking about creating a web playground sort of environment where you can edit files and run your app/game right in the browser. But this is some ways off. Probably after I do physics and networking. Currently, HTML5 support is mainly for demoing your game to a wider audience, but I do care about your use case for sure. See Amulet (another lua framework) which has a playground. (I want to say that amulet's API choices are not for me, but maybe you would like them.)

I was thinking either something like that, or perhaps embedding an editor (such as rxi/lite) directly into lyte so that any sample can be edited while being executed. That would be a powerful showcase.

Single file html... not sure how straightforward this would be. Do you know how love2d web-builder does it? Maybe embedding wasm bytecode in javascript strings... but how where would the game .zip go? I currently do not have time to investigate this, but if you do want to give this a try (a prototype) and make it work (and if it's simple enough!) I can look into incorporating into Lyte2D builds (as to create such single HTMLs.) If you'd like to further discuss this, feel free to file an issue on Lyte2D repo as well! I think a few more folks are watching it, so perhaps some discussion can happen around this :) For now your best bet (for single HTML) may be using a JS/Canvas approach. Perhaps something like Phaser?

SugarRayLua commented 1 year ago

Thank you very much, @morew4rd, for your thorough reply. I'll switch to following your Lyte2D project at the repo link you included in the future.

I have used and enjoy playing around in Amulet's playground. I still have it saved as a favorite but hadn't gone much farther in developing with it primarily for the reason I wrote to you about: I couldn't figure out a way to combine all the project files into a single html file to enable me to distribute it to family and friends to try out. I'm a novice iOS mobile programmer, and although I do understand how to and have a local web-server set up on my device, many of my friends and family are less technologically inclined and do not. Thus, it is much easier for me to just send them an html to open in their browser to test out (understanding the security concerns of their trusting me and the file that I send) then to help each of them set up local web-browsers on each of their devices (e.g. iPhone, Windows laptop, etc). It is also easier for me to not become a permanent remote web-server for them to log onto to test the apps I make. I wrote the Amulet developer a while back asking him the same question (as to whether he could set up an export process that could create single file html projects rather than separate .wasm and game files), and he indicated that he didn't know how to do so and relied on Emscripten to create the files for Amulet. I know multiple other emulator projects that combine system and project files into single html files (e.g. TRS80 emulator and R's rgl package) but haven't seen any other project besides love2d's web-builder site that does so with wasm files. I'll go ahead and write to the web-builder site's developers to see if they can offer any suggestions, and if so, try making single html files and let you know how it turns out.

I've followed Web Assembly's discord channel and periodically people talk about making inline html files with emscripten but the suggestions have not been step by step and seemed above my js programming understanding. It sounded like many Web Assembly members were waiting for updated html standards that would allow loading .wasm files directly (like javascript sources) to really make such inline .wasm practical. Yet, the Love2D web-builder site developers seemed to have figured it out, as I've used their site to build in in-line single html web versions of Love2D projects.

Thanks for letting me know about Phaser-- I didn't know about that framework. I'll try it out; I prefer programming in Lua so will also keep tabs on the progress of lyte2d (along with Love2D).

PS, Off topic: Have you tried out this developer's Love2D 3D engine/shaders? He made them all with lua in love2D, and it is pretty impressive in my opinion. Perhaps it might help where you might be planning to go with 3D in lyte 2d:

https://github.com/3dreamengine/3DreamEngine

Have a good night :-)

SugarRayLua commented 1 year ago

Follow-up:

I wrote and heard back from Love Web-Builder site developer. It turns out that it uses an older version of love.js and does not actually use web assembly/emscripten but rather just bundles project and love.js files into a single file-- so perhaps best to wait for future html standards to change to allowing web-assembly to be directly loaded into html without javascript "glue" to try and develop a single file html exporter for Lyte2D. I'll keep my eye out for any such html changes and re-visit the enhancement when that occurs.

morew4rd commented 1 year ago

Got it! Thanks for looking into this further and the follow-up! Also, thanks for the 3DreamEngine link! Looks awesome! Looks like it should be eventually possible to port it to Lyte2D as well. 👍

BTW, for your use case, did you consider using static hosting? Github for example let's you use a repo for static hosting where you can definitely host Lyte2D or Love2D games (or any other WASM based system really.) You can either use a MY_NAME.github.io based domain name, or a custom domain name.

For example apparently, I have a prerelease version of lyte2d hosting a break out clone here: https://morew4rd.com/braekout/ You can take a look at the repo contents to see how that was done. (I forgot making this, just noticed it)

It's in the settings area of your repo if you want to go this route.

If you want to keep your games private though, consider hosting them on itch.io. You can have "secret" links that you share with friends/family and delete them after a while.

Also JFYI, lyte2d 0.4 is released. Website has updated API surface so make sure to take a look!

SugarRayLua commented 1 year ago

Thank you very much, @morew4rd! I didn't know I could statically host on Github-- I will definitely look into that or the itch.io open that I also didn't know about.

I'm also excited to hear about the new lyte2d release-- I'll check it out!