- Python
- Pygame
- OOP
- Rebuilt
Pong Game (Pygame)
Classic Pong game built with Pygame. Collision detection, score tracking, input handling. OOP structure for maintainability.
This page runs a JavaScript port of the Pygame code, with the same classes and rules, so it plays in your browser. The Python version is in the code.
W/S left paddle · ↑/↓ right paddle · Space serve · P pause. On a phone, drag on your side of the court and tap to serve. First to 7 wins.
How it’s built
Paddle
Moves at a fixed speed and stays inside the court.
Ball
Bounces off walls and paddles, speeding up after each hit.
ComputerPlayer
Tracks the ball with a dead zone, so it can be beaten.
Scoreboard
Counts points and decides the winner.
Game
Handles input, the game states and drawing.
- Collision detection: rectangle overlap tests, run in small steps each frame so even the fastest ball can’t skip through a paddle.
- Bounce angle: where the ball hits the paddle sets the return angle, up to 55°, so players can aim.
- Frame-rate independent: movement uses the time since the last frame, so the game runs at the same speed on any screen.
- Tested: unit tests in Python and JavaScript cover bounces, scoring, serving and a full computer-vs-computer match.