Menu
CoddyTech

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.

main.py

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 every print and error.
  • Real pygame, not a look-alike: Surface, draw, Rect and collisions, font, transform, sprite, mask, key.get_pressed(), mouse events and time.set_timer all 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 Rect collisions 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_timer drops 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?
Yes. This page runs pygame-ce in your browser with Python compiled to WebAssembly, so there is nothing to install and no account to make. The first Play downloads Python and pygame once (about 7 MB); after that a game starts at once.
Is this real pygame?
It is pygame-ce 2.5.7, the actively maintained community edition of pygame, which you install with 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?
No. Write the game loop the usual way, with 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?
There are no files to load, so 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?
It is free and needs no account. Your edits to each example game are kept in this browser, so you can close the tab and come back. Reset puts the current game back the way it started, and the download button saves main.py to your computer.
How do I learn to make games with pygame?
Start with the examples here: change one number, press Play, and see what it does. When you want a path, learn Python first with Coddy's Python course, then build games a feature at a time: a moving player, collisions, a score, a game over screen.

Useful tools for Pygame

Free, browser-based tools that pair well with the Pygame Playground, all part of Coddy.