CDN root used by pygbag
Github repo, and older runtimes
This software does not track usage at all, even for statistics purpose so if you like it : please do not forget to star it !
--template noctx.tmplto pygbag command line when using 3D/WebGL
do not use python installed from windows store, use an official python.org build
you can check version installed with
py --list command.
If python/pygbag is not installed in your PATH env, use the command
py -m pygbag
do not use “\” a path separator, pygbag is POSIX and use “/” instead eg open(“img/my_image.png”,”rb) the change should not interfere and still work on recent Win32.
sudo rmmod ftdi_sioafter plugging devices.
Before packaging, adapt your code this way if you still want wav format on desktop :
if sys.platform == "emscripten": snd = pygame.mixer.Sound("sound.ogg") else: snd = pygame.mixer.Sound("sound.wav") # or .WAV,.mp3,.MP3
also avoid raw format like BMP for your assets they are too big for web use. prefer PNG or JPG ___
There is none actually, because pygbag is not a framework it is just a friendly web version of official CPython (nothing has been changed, just some facilities added). Most desktop code will run (and will continue to run) with only a few lines changes. This is actually true for games but for applications it can be very difficult to port, even sometimes impossible.
Try to avoid relying on CPython stdlib for web operations, gui or I/O as it is very synchronous, platform specific and will probably stay that way. As alternative using pygame or pygbag supported game engines will ensure you platform independence including access to mobile ones.
basic structure of a game should be like :
test ├── img │ ├── pygc.bmp │ ├── pygc.png │ └── tiger.svg ├── main.py └── sfx └── beep.ogg
pygbag test/main.py against it, and first goes to http://localhost:8000?-i (with terminal and debugging info, for older pygbag version use http://localhost:8000#debug instead) or http://localhost:8000 (fullscreen windowed when it is running ok)
usefull additions to your .gitignore
*.wav *.mp3 *.pyc *.egg-info *-pygbag.??? /build /dist
if using pygame zero : put #!pgzrun near the top of main ( 2nd line is perfect if file already has a shebang )
(for testing, may not always work since they use daily/weekly devel version)
Please ! use the tag pygame-wasm for your projects hosted on Github and also add a favicon.png icon 32x32 next to your game main.py, so it is picked up by default.
( expected to be stable )
nb : code is read-only, prefer right-click then open in new window.
Python Wasm explained by core dev Christian Heimes (youtube video)
pygame tech demo PyCon DE & PyData Berlin 2022
French : Python WebAssembly at PyCon FR 2023 Pour quoi, pour qui et comment
Hello from the pygame community.