Pygame Online
Write a pygame game, press Play and play it in your browser with the keyboard. Real pygame-ce, nothing to install. Free, no sign-up.
Run pygame online, right in your browser
Write a pygame program on one side and play it on the other. Press Play, click the game and use the arrow keys, the letters, Space and the mouse. Your while running: loop, pygame.event.get() and clock.tick(60) run exactly as they would on your computer. Nothing to install and no account needed.
The game runs on pygame-ce 2.5.7, the community edition of pygame, with Python 3.14 compiled to WebAssembly. It runs in your browser, not on a server, so it keeps going as long as you play. Code you write here is ordinary pygame: copy main.py to your computer, run pip install pygame-ce, and it plays the same.
What makes this pygame playground useful
- A playable window next to the code. Press Play (or Ctrl+Enter) and your game runs at the frame rate you ask
clock.tick()for, with a console under it for everyprintand error. - Real pygame, not a look-alike:
Surface,draw,Rectand collisions,font,transform,sprite,mask,key.get_pressed(), mouse events andtime.set_timerall behave as pygame documents them. - Six example games to start from: move a square, a bouncing ball, catch the falling blocks, Snake, two-player Pong and a paint program. Change a number, press Play, and see what it does.
- Runs in any modern browser, so it works on a Chromebook, a school laptop or a tablet. On a touch screen you get arrow keys and a Space button over the game.
What you can build in the pygame playground
- A Snake game: a grid of cells, a body stored as a list, food in a random place and a score drawn with
font.render. Make it faster as it grows, or add walls. - Pong for two players on one keyboard, W and S against the arrow keys: a ball that bounces with
Rectcollisions and a score at the top. Add a computer player, or speed the ball up after every hit. - Catch the falling blocks:
pygame.time.set_timerdrops a block every 0.7 seconds and a paddle catches them. Count lives, add a bonus block, or speed up as the score climbs.
Pygame online FAQ
Can I run pygame online without installing anything?
Is this real pygame?
pip install pygame-ce and import as pygame. Your code needs no changes to run on your computer. The window, the clock and the keyboard are connected to this page instead of a desktop window, which is why pygame.display.set_mode opens the game beside the editor.Do I need asyncio, like pygbag?
while running: and clock.tick(60) at the end of each frame. The page lets the browser take a turn at every tick, so the tab never freezes and your keys reach the game. Programs written for pygbag with asyncio.run(main()) run too.What does the playground not do?
pygame.image.load and pygame.mixer.Sound have nothing to open: draw with shapes and text instead. Sound is silent, every font is pygame's built-in font, there is one window of up to 1280 by 960 pixels, and there are no joysticks and no network. input() has no keyboard to read from; use pygame's events.Is it free, and is my code saved?
main.py to your computer.How do I learn to make games with pygame?
Useful tools for Pygame
Free, browser-based tools that pair well with the Pygame Playground, all part of Coddy.