Python Studio
Pick one of the games from the series, tune it, and play it right here in the browser. Then download a real Pygame project with proper main.py code and run it on any computer with Python.
Companion to the My First Python Game series. Nothing to install here, it works on a school computer.
Tune your game
These values change how the game plays here and in the exported Python. Move one at a time to feel the difference.
Place it in the world
Drag the player token where you want to start, or use Left and Right arrows then Enter to drop. The start spot saves and appears in your Python as STARTX.
Player starts in the middle. Drag it and press Play.
Play your game
On a keyboard use arrows or WASD to move, and Space or Z for the action button. Nothing happening? Go back to Tune and change a value, then press reset.
Download your Python project
This is a real Pygame project. Download the zip, then run it with Python on any computer.
Code it live
This is the real main.py. Change a number, press Apply, and the game updates here and in the download.
How to run your project
- Install Python 3 from python.org (free).
- In a terminal, install Pygame:
pip install pygame. - Unzip the download and run
python main.py. - To change the game, edit
main.pyand run it again. That is the same code you tuned here.
The Pygame game loop
- Get the events. Check what the player did (closed the window, pressed a key, clicked).
- Update the world. Move the player, the ball, the enemies, and check for collisions.
- Draw the screen. Fill the background, then draw everything in its new place.
- Flip and wait.
pygame.display.flip()shows the frame, andclock.tick(60)keeps it at 60 frames a second.
The loop runs in a while True: block, so it repeats until the player quits. Every game on the series uses this exact shape.
Keep learning
Open the Pygame cheatsheet for the drawing and event calls, or read the series for a step by step build of each game.