Six complete implementations of Pong, each in a different language or framework. Every variant implements the exact same game with the exact same physics, AI, and rules so you can read them side-by-side and see how the same concepts translate across ecosystems.
| Directory | Language | Framework | Level |
|---|---|---|---|
pygame/ |
Python | PyGame | Beginner |
html5/ |
JavaScript | Vanilla Canvas | Beginner |
love2d/ |
Lua | LÖVE2D | Beginner |
godot4/ |
GDScript | Godot 4 | Intermediate |
raylib/ |
C | Raylib | Intermediate |
unity/ |
C# | Unity | Intermediate |
All six variants share the same three-phase loop, just spelled differently:
┌─────────────────────────────────────────────────┐
│ 1. Gather input │
│ 2. Update state (move objects, check collisions│
│ 3. Render (draw everything to screen) │
└─────────────────────────────────────────────────┘
| Variant | Loop mechanism |
|---|---|
| PyGame | while running: + clock.tick(60) |
| HTML5 | requestAnimationFrame(loop) |
| LÖVE2D | love.update(dt) + love.draw() callbacks |
| Raylib | while (!WindowShouldClose()) |
| Godot 4 | _process(delta) + _draw() (engine-driven) |
| Unity | Update() + render pipeline (engine-driven) |
Every variant multiplies velocity by delta time (dt) so movement is frame-rate independent:
# PyGame
ball.x += ball.vx * dt
# LÖVE2D
ball.x = ball.x + ball.vx * dt
# Raylib (C)
ball.x += ball.vx * dt;
# HTML5
ball.x += ball.vx * dt;
# GDScript
position += velocity * delta
# Unity (C#)
transform.position += new Vector3(velocity.x * dt, velocity.y * dt, 0f);All six use Axis-Aligned Bounding Box collision — the simplest 2-D overlap test:
Two rectangles overlap when neither is entirely to the left, right, above, or below the other.
A overlaps B ⟺ A.x < B.x+B.w AND A.x+A.w > B.x
AND A.y < B.y+B.h AND A.y+A.h > B.y
All six AIs use the same algorithm: move the paddle toward the ball's y-centre, limited by PADDLE_SPEED × difficulty × dt. The difficulty factor (0.80) makes the AI beatable.
cd pygame
pip install -r requirements.txt
python pong.pyOpen html5/index.html in any modern browser. No install required.
Install LÖVE2D 11.x from https://love2d.org/
love love2d/Windows: drag the love2d/ folder onto love.exe
- Install Godot 4.2+ from https://godotengine.org/
- Open Godot → Import → select
godot4/project.godot - Press F5 to run
cd raylib
# Install raylib first (see Makefile header for instructions)
make runSee unity/README.md for full scene setup instructions.
| Key | Action |
|---|---|
W or ↑ |
Move player paddle up |
S or ↓ |
Move player paddle down |
ENTER |
Start / restart |
ESC |
Quit (where applicable) |
Each source file is heavily commented with references to the equivalent code in the other five variants. When you read about velocity * delta in the PyGame version, the comment tells you exactly where to find the same line in LÖVE2D, Raylib, GDScript, HTML5, and C#.
- Game loop and frame timing
- Delta time and frame-rate independence
- Velocity vectors and 2-D movement
- AABB collision detection
- Bounce angle variation (hit position → outgoing angle)
- State machines (menu / playing / point / win)
- Event systems (return values, callbacks, signals, C# events)
- Component vs script architectures
- Manual vs engine-driven physics