Share
GAME
PROBLEMS

Press Run to play. Click the game to give it the keyboard.

Pygame Online

Write pygame games in Python and play them right here in your browser, with nothing to install. Your game runs in the GAME tab next to the editor: the keyboard and mouse work as they do on a desktop, phones get on-screen keys, and the game can go full screen. Start from a ready-made game like Snake, Pong or Breakout, change it, and share it with a link.

How to Make and Play Pygame Games Online

  1. Pick a game, or write your own

    The editor starts with a small game. Click Examples above the editor to open Snake, Pong, Breakout and more; each one opens in a new tab and starts playing.

  2. Run it

    Click Run or press Ctrl + Enter. The game plays in the GAME tab and gets the keyboard, so the arrow keys work straight away. Click the game if you have clicked somewhere else.

  3. Read your output

    print() output, error messages and input() questions appear in the output panel under the game. Error line numbers link to your code.

  4. Play on a phone

    Touch screens get on-screen arrow keys and a Space key, plus any other keys your game uses. The keyboard button on the game turns them on anywhere, and the layout menu switches between the code and the game.

  5. Go full screen

    The full screen button on the game makes it fill the screen, scaled to fit.

  6. Share it

    Click Share to get a link to your game. Whoever opens it can play it and change the code.

Pygame Examples to Start From

Each example is a complete, commented game you can play, read and change. Open them from the Examples menu.

  • Snake A grid, a growing list
  • Collect the coins Arrow keys, a game loop
  • Bouncing balls Classes, the mouse
  • Catch the stars Falling objects, a score
  • Pong Two paddles, a simple AI
  • Breakout Bricks, lives, angles
  • Flappy bird Gravity, scrolling pipes
  • Tic-tac-toe The mouse, a simple AI
  • Guess the number input(): you type the answers
  • Paint Draw with the mouse
  • Space shooter Lasers, rocks, lives
  • Falling blocks A grid, turning pieces

How Pygame Runs in Your Browser

Your game runs on Pyodide, the standard Python interpreter compiled to WebAssembly, with pygame-ce, the community edition of pygame. Nothing is installed and nothing runs on our servers: the game plays in your browser tab, in a sandboxed frame that can't see the rest of the page.

A desktop game loop never pauses, and a browser tab can only draw when the code pauses. So before a game starts, the page makes it pause for a moment at every clock.tick() (or pygame.display.flip() if the game has no clock). You write ordinary pygame code; the same file runs on your computer.

Things to Know

  • No sound yet pygame.mixer doesn't play sound on this page.
  • Your files only Games can use Python's standard library and other tabs you create (import player loads player.py). Text files in other tabs can be opened with open(). Images and sounds from your computer can't be loaded yet.
  • Keep a clock in the loop A loop that never calls clock.tick() or pygame.display.flip() can still run, but Stop may have to close the game to end it.
  • Turtle works here too import turtle programs draw in the GAME tab. Our Python Turtle page has turtle examples to start from.
  • tkinter tkinter programs open desktop windows, which a browser can't show. Make the program a pygame game, or run it on your computer.

Frequently Asked Questions

Can I run pygame online without installing anything?

Yes. This page runs pygame-ce, the community edition of pygame, on Pyodide, a full Python 3 compiled to WebAssembly. Everything happens in your browser tab, so it works on Windows, macOS, Linux, Chromebooks, tablets and phones, with nothing to install.

Does my pygame code need changes to run here?

No. Write an ordinary pygame program with a game loop and clock.tick(). The same file runs on your computer after pip install pygame-ce (or pygame).

Can a pygame program use input()?

Yes. When your program calls input(), the output panel under the game opens and you type the answer there, as in the Guess the number example.

Can I play the games on a phone?

Yes. Touch screens get on-screen arrow keys and a Space key, plus any other keys your program uses, and the tabbed layout gives the game the whole screen.

Can I use images and sounds?

Not yet. Draw with pygame.draw and pygame.font for now. Sound from pygame.mixer does not play on this page.

Is it free?

Yes, with no account needed. Click Share to get a link to your game that anyone can open, play and change.