For teachers · Python · GCSE and A-level

A Python game engine that survives a school network

tphysics is a single-file Python game engine built for the classroom. Copy one file, import it, and students are drawing shapes, handling key presses and building games. No pip, no virtual environment and no administrator rights.

Open the browser editor Download tphysics.py

Why a single file matters

Most game engines assume a normal development machine: an installer, a package manager, a graphics library and a working build toolchain. School laptops often have none of those. tphysics makes a different trade-off. It is one file that uses the standard library and renders with turtle graphics, so the gap between opening the folder and running a game is as small as it can be.

Zero dependencies

Only the Python standard library. No pygame, no wheels, no package index and no build step.

One file to copy

Put tphysics.py beside the student's program and from tphysics import *.

Readable source

The engine is deliberately small and commented, so students can look inside the abstraction rather than treat it as magic.

Runs in the browser

If local Python is impossible, the same examples run at tphysics.uk with no install at all.

What students can build

The repository includes complete examples rather than isolated snippets:

The engine provides rectangles, circles, text and input events. That is enough for a first game project without the overhead of sprites, scenes, audio and an asset pipeline.

How it compares with pygame-zero

pygame-zero is excellent and more capable: it wraps pygame, supports images and sound, and has a large community. It also needs pygame installed. tphysics is narrower on purpose.

tphysicspygame-zero
InstallCopy one fileInstall pygame and pgzero
RenderingTurtle graphicsPygame / SDL
Feature setShapes, text, keyboard, mouseSprites, images, sound, more
Classroom fitLocked-down machines, first gamesMachines where installs are allowed

If your students can install packages and need sprites or audio, use pygame-zero. If the install is the blocker, tphysics is the smaller step.

Getting started in a lesson

  1. Download tphysics.py from the repository.
  2. Put it in the same folder as the student's Python file.
  3. Start with from tphysics import * and one of the example programs.
  4. Change a value, run it again, and let the visual result drive the explanation.

No local Python? Open the browser editor, load an example and run it there. The editor has the engine and the examples built in.

Teaching resources

Frequently asked questions

Does tphysics need pygame or any other package?

No. tphysics uses only the Python standard library, including turtle and tkinter. The whole engine is one file, tphysics.py.

Can students use tphysics without installing anything?

Yes. Students can download tphysics.py and place it next to their own program, or use the browser editor at tphysics.uk. The browser version needs no local Python installation.

What can students build with tphysics?

The included examples cover key presses, mouse clicks, collisions, text and buttons, plus games such as Pong, Flappy Bird, a platformer, an aim trainer and chase games.

How is tphysics different from pygame-zero?

pygame-zero is a zero-boilerplate wrapper around pygame and needs pygame installed. tphysics is a single standard-library file that renders with turtle graphics. It is deliberately smaller than pygame-zero: rectangles, circles, text, keyboard and mouse input, with no sprite or audio engine.

Does tphysics work on school computers with restricted installs?

That is the main use case. If Python with tkinter is already present, copying one file into the project folder is enough. If Python cannot be installed at all, use the browser editor.

Is tphysics free?

Yes. tphysics is free and open source, with no account, licence fee or classroom subscription.

Try it

Open the tphysics browser editor to run an example now, or read the source and examples on GitHub.