Brygame ยท pygame in the browser

The real pygame-ce (the upstream C) compiled to WebAssembly, running on wasthon (Brython + C modules) โ€” in the browser, with no install. All the demos and test benches.

๐ŸŽฎ

The product โ€” 1 include

A page is just <script src="wasthon-pygame.js"> + 100% standard pygame code. Bricks, sprites, text. Zero plumbing.

wasthon-pygame.js
โ™พ๏ธ

Desktop pygame VERBATIM

The exact desktop tutorial code โ€” while True, clock.tick(60), sys.exit(). The loader lifts the loop onto the browser frame clock at load time. No adaptation at all.

while True
๐Ÿงฑ

Animated breakout โ€” 1 include

A real 60 fps game via wasthon-pygame.js: bricks, score, lives, pygame.run(frame) for the loop. Arrows / A-D, space.

the game
๐ŸŽฏ

Breakout (explicit bootstrap)

The same idea but with the bootstrap spelled out โ€” handy to understand the rAF loop under the hood.

educational
โœ…

Feature suite

~40 tests: Surface/blit, PNG images, Color, Vector2, Rect, time, key, font, mixer, transform + a mini perf bench. Click the canvas = ๐Ÿ”Š beep.

40 OK / 1 (upstream)
โšก

Perf bench โ€” sprites

How many sprites at 60 fps? A widget to set the count by hand, batched draw via Surface.blits(), live measured fps.

~350 @ 60 fps
๐Ÿ“ฆ

standard import pygame

import pygame, from pygame.locals import *, pygame.sprite.Sprite โ€” via the real package __init__.py.

productization
๐Ÿ”ฌ

Runtime probe

The diagnostic bench that unblocked everything: Rect, set_mode, fill/draw, canvas memory forensics.

debug / forensic
๐Ÿ–ผ๏ธ

Dear ImGui (bonus)

The binding that proved the infra (SDL2 + WASM + bridge) reused by pygame: a widget GUI driven from Python.

gui-poc