I'm making a game with Python, using Pygame. I want to publish my game on itch.io so that it's playable in the browser.
Is there a way to do this? If so, how?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
A game made with Pygame is not playable in the browser. Games made with that tool can be put on itch, but only as a downloadable desktop package, not as a web game.
For completeness, I should mention there are a few projects that aim to get Python/Pygame working in a browser, but I would not call any of these a great option. The most prominent of these projects is Skulpt, and here are some examples of using it with Pygame.
Refer to this existing closely related question.
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.
To publish your game on itch.io as some people have already done ( as can be seen on https://itch.io/c/2563651/pygame-wasm )
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