Pi(e) Invaders: a Pi Day Themed Arcade Game

by maxcarvajal14 in Design > Software

256 Views, 0 Favorites, 0 Comments

Pi(e) Invaders: a Pi Day Themed Arcade Game

Pie Invader.gif
Pi Invader.gif

Many people celebrate Pi Day by eating delicious slices of pie or watching Life of Pi, blissfully unaware of the very real and deeply tragic history behind March 14th.

Years ago in a distant galaxy not entirely unlike our own, Pi Day marked the beginning of a long and seemingly unending feud between two civilizations: the Pis and the Pies.

What began as a simple numerical disagreement quickly escalated into full-scale conflict. The Pis, irrational and relentless, launched a devastating invasion on Pie Earth. The Pies, flaky but resilient, fought bravely to protect Pie Earth’s crust, but history has largely forgotten their struggle.

In this project, you’ll step into the role of a pi(e)lot, defending the surface from waves of incoming digits and doing your part to preserve what remains. Of course, history is written by more than one side… and depending on how you look at it (the settings you choose), you may find yourself defending a very different home from an equally determined pastry counter-strike.

My goal with this project is to give people a chance to relive the infamous Pi Day invasion, this time from the front lines. Additionally, having never built my own game or worked with the Pygame Python library, this felt like the perfect excuse to start. In this project, I will guide you through setting up and running the Python application so you can play the game yourself. I’ll also walk you through the code layout so you can tweak the game’s structure and/or theme.

Supplies

Software

  1. Python 3.11 (3.10-3.13 seem to work, but primarily tested on 3.11)

Tools

  1. A code editor (Here I use Visual Studio Code, but there are many others)
  2. Terminal / Command Prompt

Files

  1. The Pi(e) Invaders project ZIP Downloadable here

Hardware

  1. A computer running Windows, macOS, or Linux

Download & Set Up the Project

Screenshot from 2026-04-26 23-17-06.png
Pi Invader Setup (3).gif
Pi Invader Setup (1).gif
Pi Invader Setup (2).gif

1. Check if Python Is Installed

First, you’ll need to open a command line terminal.

If you’ve never used a terminal before, don’t worry, you’ll just be typing a couple simple commands.

Windows:

  1. Press the Windows key, type cmd, and press Enter
  2. (or open any folder, click the address bar, type cmd, and press Enter)

Mac:

  1. Press Cmd + Space, type “Terminal”, and open it

A black (or dark) window should open. This is the terminal.

Now run:


python --version

or if that doesn't work try:


python3 --version

If you see a version number, you’re good to go.

If you don't see a version number, download and install Python before continuing here. Remember to install a version in the range 3.10-3.13

2. Download and Extract the Project

  1. Download the Pi(e) Invaders code from github: https://github.com/maxC14/pi_invaders
  2. Press the green code button
  3. Press 'Download ZIP' from the drop-down
  4. Extract it to a location you can easily find (e.g. Desktop or Documents)

After extracting, your folder should look something like:

pi_invaders/
pyproject.toml
main.py

3. Open a Terminal in the Project Folder

Now we want the terminal to point to your project folder.

Windows:

  1. Open the folder
  2. Click the address bar, type cmd, and press Enter

Mac/Linux:

  1. Right-click inside the folder → “Open in Terminal”
  2. If the above option is unavailable (on MacOS I believe it must be enabled) you can open the terminal and use the following command replacing the folder path below as needed
cd Downloads/pi_invaders-main/


4. Install the Project

Run:


pip install -e .

This installs the project and its dependencies, while allowing you to modify the code without reinstalling.

If pip doesn’t work try:


python -m pip install -e .

or

python3 -m pip install -e .


Now that you have installed the necessary software/software tools let's see how to actually run and play the game.

Run the Game

Screenshot from 2026-04-26 19-31-13.png
Screenshot from 2026-04-26 19-31-21.png

Now that everything is set up, it’s time to launch the game and begin the defense of Pie Earth's Crust (or Pi Earth depending what team you choose).

1. Start the Game

From the project folder (the same place as main.py), run:

python main.py

or, if needed:

python3 main.py

2. What Should Happen

A game window should open with the main menu.

If everything is working, you should see the menu within a few seconds and be able to start the game.

If nothing happens:

  1. Make sure you are in the correct folder
  2. Double check that Step 1 completed without errors

3. Controls

  1. Left / Right Arrow keys or A / D → Move
  2. Spacebar → Shoot
  3. P or ESC → Pause
  4. Q → Quit

4. Settings

From the main menu or pause menu, you can adjust:

  1. Theme (Team Pi or Team Pie)
  2. Difficulty Settings (Number of Starting Lives and the initial Enemy Fall Speed)

Feel free to experiment here before jumping into the game.

5. Play the Game

Play the game and see how long of a Pi streak you can build.

Game Mode Notes

Team Pie Mode

Enemies are the digits of π, spawned in order, with the next correct digit highlighted in green.

Shoot the correct next digit with your whipped cream bullets to extend your streak.

Hit the wrong digit or fail to defend Pie Earth’s crust and your streak resets.

Team Pi Mode

Your bullets are the digits of π.

Hit incoming pies with each correct shot to maintain your streak.

  1. Miss a shot and the streak resets.


Now that you’ve played the game, let’s take a look at how it works and how you can start modifying it.

How the Game Is Organized

Screenshot from 2026-04-26 22-11-09.png
Screenshot from 2026-04-26 18-36-55.png
Screenshot from 2026-04-26 18-37-05.png

Now that you’ve played the game, let’s take a quick look at how everything is structured. This will make it easier to modify or extend the game if you choose to.

1. Entry Point

The game starts from:

main.py

This file runs the core Pi Invaders game loop: it initializes pygame, handles menus/input, updates the player, the bullets and the enemies, manages scoring/streak/level/health state, and renders each frame.

It also coordinates mode-specific behavior for Team Pie vs Team Pi, including pi-digit targeting, streak resets, game-over stats, and window resizing.

2. Game Objects

The active entities used during gameplay are defined in the files here:

pi_invaders/game_objects/

Specifically the files are:

  1. player.py - The player ship
  2. enemy.py - The falling enemies
  3. bullet.py - The bullets/projectiles

These classes defined in each of these files handle their own movement, drawing, collision rectangles, and mode-specific visuals like whipped cream bullets, pi-digit bullets, digit enemies, whole pies, and stale pi symbols.

3. Game Settings and Assets

The game’s configuration and shared assets: colors, fonts, image loading, tune-able options, game modes, pi digit generation, and constants like frames per second (FPS), spawn timing, and scoring are housed here:

pi_invaders/game_settings/

Files in this folder define behavior of the two game modes (Team Pie vs Team Pi), what images they use, and what game settings the menus can modify.

Some key files include:

  1. settings.py → general game configuration
  2. game_modes.py → logic for setting the game modes for Team Pi and Team Pie
  3. pi_digits.py → Handles fetching the next digit in pi
  4. colors.py, fonts.py → visual styling

And inside:

images/

You’ll find:

  1. Earth and Pie graphics
  2. Player and enemy visuals
  3. Bullet sprites

This is the easiest place to customize the look and theme of the game.

Beware if adding or replacing images, try to use centered RGBA PNGs with transparent backgrounds, so the game can scale and draw them cleanly without visible backgrounds or cropping.

4. Utilities

Additional functions to help with setting up the game are organized here:

pi_invaders/utils/

These handle things like:

  1. drawing to the screen
  2. menu setup
  3. general game logic helpers


5. Where to Start Modifying

If you’re new to pygame and/or python, start with simple changes:

  1. Swap out images in game_settings/images/
  2. Adjust difficulty or behavior in game_modes.py or settings.py
  3. Modify colors or fonts


Now that you understand the structure, let’s start customizing the game and making it your own.

Game Customization

Screenshot from 2026-04-26 21-13-50.png
Screenshot from 2026-04-26 19-34-53.png

Now that the game is running, and we have a better understanding of the code layout, let’s make a few simple changes directly in the code. These edits are small, but they can quickly change how the game looks and feels.

1. Change the Team Pie Player Image

Maybe you are not a cherry pie loyalist. Maybe you believe pumpkin pie is the true defender of Pie Earth’s crust. To change the player image, replace the filename with another image in your assets folder:

Open:

pi_invaders/game_settings/game_modes.py

In PIES_MODE, look for:


player_image="cherry_pie.png",

This controls the player image for Team Pie mode.

To change the image, replace the filename with another image from the game’s image folder (I've gone ahead and prepared a pumpkin pie image already):


player_image="pumpkin_pie.png",

Save the file, rerun the game, and select Team Pie mode to see the change.

If you want to use your own image, make sure it is a transparent PNG. Optionally a tool like Pillow can also be used to resize or preprocess images before adding them to the game.

2. Change the Player Size

Right below the player image, you’ll see:


player_size=(120, 120),

Try changing it to:


player_size=(90, 90),

This changes how large the player appears on screen.

3. Change Bullet Speed

Open:

pi_invaders/game_settings/settings.py

Find:


BULLET_SPEED = 10

Try increasing it:


BULLET_SPEED = 18

Save the file and rerun the game.

Faster bullets can make the game feel more responsive, but they can also change the difficulty, especially in Team Pi mode where missing a shot resets your streak.

4. Try Other Easy Changes

Once you are comfortable editing these files, try changing:


ENEMY_SPEED_START = 1.5

This controls how fast enemies move at the start.


SPAWN_INTERVAL_MS = 1200

This controls how often enemies appear. A smaller number means more enemies.


EARTH_HEALTH_START = 5

This changes how much damage Earth can take before the game ends.


DIGITS_PER_LEVEL = 10

This changes how often the difficulty increases.


At this point, you are no longer just playing Pi(e) Invaders. You are actively reshaping the Pi Day conflict. These changes are just the beginning. If you want to go further, you can explore files like main.py and the rest of the codebase to start modifying the core game logic and create entirely new behaviors. There are also many tutorials available for Pygame if you want to dive deeper into game development.