Tirsvad 61fb78a259
TirSystem/git-workflows: Publish wiki / publish-wiki (push) Skipped
TirSystem/git-workflows: Release / release (push) Skipped
TirSystem/git-workflows: CD / changes (push) Successful in 8s
TirSystem/git-workflows: CI / secret-scan (push) Successful in 12s
Tests / test (push) Successful in 44s
TirSystem/git-workflows: Sync GitHub mirror metadata / sync-metadata (push) Successful in 6s
TirSystem/git-workflows: Publish accepted milestones / publish (push) Successful in 14s
TirSystem/git-workflows: OpenGrep / opengrep (push) Successful in 1m3s
TirSystem/git-workflows: Validate / validate (push) Successful in 21s
TirSystem/git-workflows: CI / validate (push) Successful in 17s
TirSystem/git-workflows: CI / opengrep (push) Successful in 52s
TirSystem/git-workflows: CI / release-check (push) Successful in 5s
TirSystem/git-workflows: CD / wait-for-ci (push) Successful in 1m21s
TirSystem/git-workflows: CD / release (push) Skipped
TirSystem/git-workflows: CD / publish-wiki (push) Skipped
TirSystem/git-workflows: CD / sync-metadata (push) Successful in 6s
TirSystem/git-workflows: CD / sync-milestones (push) Successful in 14s
Merge pull request 'Record the check of the published wiki' (#34) from wiki-published-check into main
2026-11-21 11:37:34 +01:00
2026-11-21 17:32:24 +08:00
2026-11-21 09:50:38 +01:00

🚀 Space Invaders

The classic Space Invaders shoot 'em up for one player, built with Python's turtle module as the Day 95 assignment of Udemy's 100 Days of Code: The Complete Python Pro Bootcamp. You steer a spaceship left and right and shoot the alien ships; every second the aliens move closer, and when they touch your ship the game is over. Barriers offer defensive positions. It has no runtime dependencies.

📚 Table of Contents

🧭 Overview

The game is built in nine steps, one branch and one pull request per step. The guides, with a screenshot of every step and what each step taught, are in the project wiki, in English, Dansk and Bahasa Melayu.

Build steps

Each step is one branch and one pull request. The wiki explains what each step taught.

Step 1: Game screen. A black window and a frame loop. (wiki)

Game screen

Step 2: Spaceship. The ship moves left and right and stops at the edges. (wiki)

Spaceship

Step 3: Shooting. Space fires one bullet at a time. (wiki)

Shooting

Step 4: Alien fleet. Five rows of eight aliens. (wiki)

Alien fleet

Step 5: Alien movement. Every second the fleet moves closer. (wiki)

Alien movement

Step 6: Shooting aliens. A bullet removes an alien; the fleet speeds up. (wiki)

Shooting aliens

Step 7: Barriers. Barriers absorb bullets and wear out. (wiki)

Barriers

Step 8: Game over and win. Aliens touch the ship: game over. No aliens left: you win. (wiki)

Game over and win

Step 9: Score and lives. Score, lives and the aliens' return fire. (wiki)

Score and lives

Project layout

Path Contents
.editorconfig Editor settings of the framework baseline
.env.example Placeholders for the tokens of the framework scripts
src/ Game source; every constant is in constants.py
tests/ pytest tests
tools/ Docker image and script that take the screenshots on a virtual display
docs/ Project documents, docs/wiki/ (the wiki) and docs/images/ (screenshots)
framework/ SQA and QC framework (git submodule)
pyproject.toml Project configuration
Doxyfile Doxygen configuration

📋 Requirements

  • Python 3.14 or newer, with Tk support (turtle needs it)
  • git
  • Doxygen (optional, only to build the source documentation)
  • Docker (optional, only to take the screenshots)

🛠️ Setup

Clone the repository, then create and use a local .venv and update pip inside it.

git clone ssh://git@git.tirsystem.com:10022/Tirsvad-Udemy-100-days-of-code/095-assignment-space-invaders.git
cd 095-assignment-space-invaders

Windows PowerShell

py -3.14 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Linux and macOS

python3.14 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

On Debian and Ubuntu, turtle needs the Tk library: sudo apt install python3-tk. Leave the environment with deactivate. The game itself needs no installed package, only the standard library; the dev extra adds pytest.

▶️ Run

With the .venv active:

python src/main.py

Controls: Left and Right arrow keys move the ship, Space fires.

🧪 Tests

With the .venv active:

python -m pytest

Tests that open a turtle window are skipped on your machine, so a test run never takes over your desktop. They run in the Docker container on a virtual display:

docker build -t space-invaders-shots tools
docker run --rm -v "$PWD:/work" -e SPACE_INVADERS_GUI_TESTS=1 -e PYTHONPATH=src --entrypoint bash space-invaders-shots -c "timeout 120 xvfb-run -a python -m pytest"

Optional checks:

doxygen Doxyfile

Before every push, scan the working tree with the local opengrep binary and fix every finding. On Windows (PowerShell):

& "$HOME\.opengrep\cli\latest\opengrep.exe" scan --config auto --error .

Screenshots

The screenshots are taken inside a Docker container on a virtual display, so the game never opens on your desktop:

docker build -t space-invaders-shots tools
docker run --rm -v "$PWD:/work" space-invaders-shots step-01-screen 3

The arguments are the file name (written to docs/images/), the seconds to wait and, optionally, key names to press, for example Left Left space. Set -e SCENARIO=tools/scenarios/game_over.py to run a prepared situation (for example a lost game) instead of src/main.py.

📄 License

GNU Affero General Public License v3.0 or later; see LICENSE.

📎 Appendix: Project documents

The documents a newcomer needs, in reading order.

Document What it tells you
AGENTS.md The rules agents follow in this repository
Business Case Why the project exists, its scope and success criteria
Stakeholder Analysis Who is involved; the stakeholder IDs used for owners and reviewers
Project Plan The gateways and their schedule
Milestones One document per gateway: Go/No-Go criteria and tasks
Artifact registry Where each artifact type lives, the next version, the PO language and domain
Framework README The framework this project uses
Framework changelog What changed in each framework release

S
Description
Classic Space Invaders shoot 'em up built with Python Turtle - Udemy 100 Days of Code, Day 95. Built in nine steps with tests, Doxygen docs and a wiki in English, Danish and Bahasa Malaysia.
https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/095-assignment-space-invaders/wiki Readme AGPL-3.0
364 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 96.3%
Shell 2.5%
Dockerfile 1.2%