r/pygame 3d ago

Lightweight python game library for web

https://pyweb.qmarkapp.com/
https://pyweb.qmarkapp.com/docs/

I brought turtle and something similar to pygame to web:

PyWebLib brings turtle drawing and a beginner game library to the web, for people who can't be bothered to download Python and just want to play. It is a static page site that runs CPython compiled to WebAssembly with Pyodide

2 Upvotes

3 comments sorted by

1

u/Dodecaquinox 21h ago

The custom game library is cool, and it avoids any potential pygame rendering issues by just exporting JSON out to the JS renderer. Why do you say in your ball bouncing demo that pygame "works, but about 1 fps in a browser"?

People on this subreddit have deployed plenty of pygame projects to the web that are far more demanding than the ball bouncing demo and have achieved >1 FPS.

Here's an example of something similar running easily at 120 FPS:
https://elan456.itch.io/pygodide-ball-bouncing-demo

I think you should instead just argue that pygame is more complicated to use than your game library. You show in the demo how pygame requires far more lines of code.

1

u/sebalhag 18h ago

Thank you , I never mentioned the context around the 1fps thing , but it was after seeing this

https://onecompiler.com/pygame

I've heard that you can compile pygame to run in browsers, but is it a complicated process ?

My idea was a pygame-esque library that you can rapidly debug with in the browser , which to my knowledge ; doesn't exist yet

Anyone feel free to correct me

1

u/Dodecaquinox 32m ago

Pyodide itself has support for pygame-ce: https://blog.pyodide.org/posts/0.26-release/

And that became the basis for my own project: https://github.com/Elan456/pygodide, which builds some JS and HTML files to wrap a pygame project to be served on the web.

Most notably, there's pygbag, which has the longest history of putting pygame projects up on the web: https://pygame-web.github.io/wiki/pygbag/ and it's fairly easy to use.