1
\$\begingroup\$

Is there any framework or method that will allow to use browser to run a 2D game made in python with pygame graphical library?

\$\endgroup\$
3
  • \$\begingroup\$ The existence of sites like Python Fiddle, myCompiler, etc. seem to answer the question "is it possible to run Python code through a browser". Note that the browser isn't actually running Python code natively in these examples. The Python code is either running on a server with the output streamed to the browser to display, or it's being emulated in JavaScript through some type of transpiling. That's enough to show technical feasibility, but it doesn't mean it's a good idea for games. Why do you want to do this? \$\endgroup\$
    – DMGregory
    Commented Mar 31, 2022 at 11:11
  • \$\begingroup\$ @DMGregory well, I just want to make a simple game that will not require to install anything on the gamers PC. I thought that was pretty obvious tbh, am I missing something here? \$\endgroup\$
    – GKozinski
    Commented Mar 31, 2022 at 11:30
  • 1
    \$\begingroup\$ JavaScript would be a more typical language choice for that use case, since browsers run it natively. Anything you do in a browser these days will be going through JavaScript at some level, so having another language under that is an extra complication you'd likely want to avoid unless you have a hard requirement of some kind. \$\endgroup\$
    – DMGregory
    Commented Mar 31, 2022 at 11:31

2 Answers 2

1
\$\begingroup\$

Since mid-2022, pygame has partial support for WebAssembly as upcoming python3.11 and allows for running the same pygame code on desktops and mobile/web.

You can publish your game on itch.io or github pages as some people have already done.

use pygbag from https://pypi.org/project/pygbag , some documentation is available from pygame-web.github.io

read documentation to adjust your main loop for async, and then use python3 -m pygbag game_folder_with_all_extra_modules_and_assets/main.py

\$\endgroup\$
-1
\$\begingroup\$

use replit https://replit.com/~. if you want to make your own website with your game iframe a replit in html

\$\endgroup\$
1
  • 2
    \$\begingroup\$ This concept is not super intuitive, could you show an example on how you'd do this? \$\endgroup\$
    – Vaillancourt
    Commented Apr 29, 2022 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .