AlexGames: simple Lua games in a browser with multiplayer support, self hosting friendly.
from axby@lemmy.ca to selfhosted@lemmy.world on 05 Apr 2024 23:28
https://lemmy.ca/post/18821047

TL;DR: try my Lua web games here, see github for self-hosting instructions: alexbarry.github.io/AlexGames

Hi all, here’s a hobby project I’ve been working on: I wrote a bunch of simple Lua games, compiled the Lua interpreter to web assembly, and defined a simple API to draw on a canvas and handle input. It all builds to static HTML/JS/WASM, except a few hundred lines of python for a websocket server for multiplayer. I recently added some dockerfiles so I think it should be easy to self host.

Here is the web version on github pages: alexbarry.github.io/AlexGames/ , and the source on github (self-hosting instructions in the README).

I’ll list some of the games:

[1]: it may not technically be multiplayer, but my partner and I enjoy picking our own hidden word and sharing the puzzle state as a URL or just passing a phone to each other.

Part of my motivation is to avoid ads on mobile games, and to be able to play different multiplayer web games with friends without having to get them to make an account and all that (just share the generated URL, it contains a multiplayer session ID). I also like the idea of having my own private web games server, and not having to be reliant on some service that might eventually get enshittified.

I figure that if I can throw together a similar game in a few hundred lines of Lua, then no one should have to deal with full screen ads or pay ~$10 to play them. Especially since most mobile games that I like are simple and I only play them for a few minutes at a time, maybe only a few times per week.

Self hosting isn’t necessary to try it out, but without SSL it should just be a simple one-line command to host the HTTP and websocket server with docker compose. For SSL support it is a few more steps, I added steps to the README: one command to build the static HTML (so you can copy it to your web hosting server, which should already take care of SSL), and another to host the websocket server, which can have your SSL certs passed as parameters. But you don’t strictly need the websocket server, it should just fail to connect after a few seconds and then you can play the games without network multiplayer. You can even use my websocket server and your own static HTML, just add &ws_server=wss://alexbarry.net:55433 as a URL parameter to your own URL. I haven’t self hosted much on my public server, so I’d love to hear feedback on how to better handle SSL certs. Ideally you could just choose to not use SSL for your websocket server, but firefox at least prevents you from connecting to a websocket server without SSL if you’re using SSL to visit the page itself on the same server. (On a local network without SSL it’s fine, though)

Some features that I’m proud of:

Let me know what you think! I’d love to hear feedback, or get new game contributions or bug fixes / features.

#selfhosted

threaded - newest

pcouy@lemmy.pierre-couy.fr on 06 Apr 2024 09:39 next collapse

I did not try it out yet, but I will make sure I do. I love a lot of things about the approach you described

axby@lemmy.ca on 06 Apr 2024 16:01 collapse

Message me on matrix in #alexgames:matrix.org if anyone wants to try playing a multiplayer game together :)

(I’m not actually very good at chess or go)