Skip to content

Getting Set Up for Pygame Turbo

Over the next several labs you'll build real video games: an alien dodging a bee, tanks that hunt you down, weights falling from the sky, and an infinite runner with costumes and a Game Over screen. Every game studio starts somewhere. Ours starts with a folder named images.

Turbo? What happened to Zero?

Pygame Turbo is a newer, faster-moving version of the Pygame Zero library. Nearly everything works the same way, and it adds a few tools we'll use — most notably a built-in way to animate characters. If you run across Pygame Zero code online, it will look very familiar.


Overview

In this lab you'll install the Pygame Turbo library in Thonny, make a home folder for your games, download every image and animation the whole unit needs in one zip file, and run a tiny test program to prove your setup works. Ten minutes here saves a headache in every lab that follows.

Before you start

Open Thonny. If you can't find it on your computer, ask for help before continuing.

You've got it when…

  • pgturbo shows as installed in Thonny's package manager.
  • You have a Pygame Turbo folder with folders named images and animations inside it.
  • The images folder holds all 41 game images from the download, and the animations folder holds four more folders of animation frames.
  • Your test program opens a window with the alien on a sky-blue background.

Collaboration & AI

Work: On your own. Ask a neighbor for a hand if you're stuck, but do the setup on your own computer.

AI — AIAS Level 1, No AI: This lab is about learning where your files live, and only you know where you put them. What the levels mean.


Install Pygame Turbo

Thonny comes with Python built in, but the Pygame Turbo library is a separate piece. Thonny has a package manager for exactly this job, so there's nothing to download from a website.

  1. In Thonny, open the menu Tools ▸ Manage packages…

  2. Type pgturbo into the search box at the top and click Search on PyPI.

  3. Click pgturbo in the search results, then click Install. When the progress messages stop, click Close.

Warning

The package is named exactly pgturbo — no spaces, and no "pygame" in front. Similarly named packages are not the library we want. In particular, pgzero is the older library this one grew out of; it won't run the programs in this unit.

Info

If pgturbo already appears in the list of installed packages when the window opens, someone has beaten you to it. Skip to the next section.


Make a Home for Your Games

Every game you write in this unit will live in one folder, next to a shared images folder and a shared animations folder. Keeping them together is not just tidiness — Pygame Turbo only looks for images in a folder named images sitting beside your program, and for animations in a folder named animations in the same place.

  1. In your Documents folder (or wherever your teacher tells you), create a new folder named pygame-turbo.

Download the Game Images

Your games will star an alien, a bee, two tanks, some hearts, and a small wardrobe of runner costumes. All 41 images, plus the animation frames for the bee and the three costumes, are in one zip file.

  1. Download the zip file.

    Download pygame-turbo-images.zip

  2. Double-click the downloaded file to unpack it. On Windows, right-click it and choose Extract All… instead. Either way, you end up with two folders, images and animations.

  3. Move both folders into your pygame-turbo folder.

Warning

The folders must be named exactly images and animations — all lowercase, no spaces — and they must sit inside your pygame-turbo folder, next to the programs you'll write. Pygame Turbo will not look anywhere else.

What's in the zip?

All 41 images for the whole unit, so you only do this download once. Each lab also offers its own images as individual downloads, in case one ever goes missing. The animations folder holds four folders — bee, ninja, dino, and knight — each a numbered series of pictures that Pygame Turbo can play like a flip book. You'll meet them in labs 30 and 100.


Test Your Setup

The smallest possible game will tell us whether everything is in the right place.

  1. In Thonny, create a new program and save it as alien_test.py in your pygame-turbo folder — next to the images folder, not inside it.

  2. Type this program.

    alien_test.py
    import pgtrun
    
    WIDTH = 800
    HEIGHT = 600
    
    alien = Actor("alien")
    alien.x = WIDTH / 2
    alien.y = HEIGHT / 2
    
    def draw():
        screen.fill("skyblue")
        alien.draw()
    
    pgtrun.go()
    
  3. Run your program with the Run button (or press F5). Your screen should look like this.

    The alien centered in a sky-blue Pygame Turbo window.

The bookends

Two lines in that program do jobs our old editor used to do for us. import pgtrun is the first line of every game — it loads the Pygame Turbo library. pgtrun.go() is the last line — it starts the game running. Everything between the bookends is your game. Every program in this unit begins and ends exactly this way.

Where did the alien come from?

Actor("alien") found alien.png in your images folder by name — no .png needed. That's the whole reason the folder matters.

Checkpoint

If the alien is on your screen, your setup is done and every lab in this unit will find its images and animations. If you got an error instead, check that alien_test.py sits next to (not inside) the images folder, and that the folder name is exactly images. An error like No module named 'pgtrun' means the library isn't installed — go back to Install Pygame Turbo at the top of this lab.


Turn It In

  • Submit your alien_test.py file in Google Classroom.

How It's Graded

This lab is worth up to 4 points. One score covers everything you turn in.

Score What it looks like
4 — Excellent Your alien_test.py runs as-is: a window opens with the alien centered on sky blue. That only happens when everything upstream is right — pgturbo installed, all 41 images inside a folder named exactly images with the animations folder beside it, and your program saved next to those folders, not inside them.
3 — Above Average The setup works with a minor slip you had to fix along the way — the file saved in the wrong spot and moved, or a mistyped folder name corrected at the checkpoint.
2 — Average pgturbo is installed and the folders exist, but the test program errors or was never finished — or the animations folder never made it out of the zip.
1 — Below Average Little of the setup done — no images folder in place, or no test program at all.
0 — Failing Nothing submitted, or no evidence of the setup.