lordmauve / adventurelib

A minimal library for writing text adventure games in Python 3
https://adventurelib.readthedocs.io/
MIT License
153 stars 42 forks source link

Allow adventurelib games to be built to run in the browser #11

Open lordmauve opened 6 years ago

lordmauve commented 6 years ago

In order to distribute adventurelib games, it would be convenient to be able to build them into a single HTML file that can be hosted on a static webserver or e-mailed to friends.

The idea would be to use one of the several browser-based Python implementations to run the code or transform it to Javascript. While the compatibility of these implementations may not be perfect, I would expect that many adventurelib games are simple enough to run without issue.

@flexo made a start on this at Pycon UK - work is at flexo/adventurelib@cd0d0db2f2d7a6118892fcf710623499badca025

lordmauve commented 6 years ago

@amigrave had some success doing this with Pyodide at the Europython 2018 sprints.

KeyWeeUsr commented 6 years ago

Single HTML would do just by creating a convenient HTML template that validates through W3C validator. Re the JS, perhaps there is no need for that and the whole source might be just used as a Brython within <script> tags. :)

lordmauve commented 5 years ago

I have added the Brython branch with some code to explore running games in the browser. Brython seems to have come a long way; this is very workable now.

lordmauve commented 5 years ago

I think the next steps is to add a CLI tool that will pack Brython, the game scripts (noting that more than one is allowed), and the HTML framework into one HTML file. It will be a large HTML file but distributing one file is so much easier than many, especially for beginners.

Much of the Brython standard library will be useless so perhaps we could trim this.

lordmauve commented 5 years ago

A suggestion at PyCon UK was to also provide a browser based IDE for adventurelib games.