Built with the tools and technologies:
Python | Pygame | dataclasses | Enum | JSON (local storage) | OOP
Space Ping Pong is a colorful, fast-paced desktop game. It features a starfield background, particle effects, power-ups, screen shake, a high-score table, and both Single-player (vs Computer) and Local Two-player modes. The animated menu lets you pick a mode, toggle difficulty (E/M/H), view high scores, and exit.
The game stores high scores locally (JSON), so your top results persist between runs.
- Two Modes: Play vs Computer (AI) or Local Human vs Human.
- Dynamic Feel: Particle bursts, pulsing menu text, starfield, and subtle screen shake.
- Power-ups: Speed Boost, Paddle Grow/Shrink, Shield, Multi-Ball, and Freeze.
- High Scores: Auto-saved locally and shown in a dedicated screen.
- Lightweight: Only external dependency is
pygame.
- Animated main menu with difficulty toggle (E/M/H).
- AI opponent with difficulty scaling.
- Local 2-player option (separate key bindings).
- Multiple power-ups with visual feedback.
- Particle effects for hits/scoring and a trailing ball effect.
- Persistent high scores (JSON file).
- Clean, modular Python code split across multiple files.
Follow these steps to set up and run the project on your machine.
- Python 3.8+
- pip (Python package manager)
-
Clone the repository (or download the source code):
git clone https://github.com/brej-29/space-ping-pong.git cd <repo-name>
-
Install dependencies:
pip install -r requirements.txtThis game runs out-of-the-box. Optional tweaks:
- Window & FPS: edit SCREEN_WIDTH, SCREEN_HEIGHT, and FPS in settings.py.
- Default Difficulty: in game.py (self.difficulty = Difficulty.MEDIUM), change to EASY or HARD.
- High Scores file path: adjust in storage.py if you want to store it somewhere else (e.g., a data/ folder).
Run the game from the project root:
python main.pyIf you’re using a virtual environment, activate it first (see above).
.
├─ LICENSE
├─ README.md
├─ requirements.txt
├─ gifs/
│ └─ space-ping-pong.gif # gameplay preview (update name if different)
├─ main.py # entrypoint (runs the game)
├─ game.py # Game loop, states, drawing, event handling
├─ settings.py # screen size, FPS, colors, etc.
├─ enums.py # GameState, Difficulty, PowerUpType
├─ vector.py # lightweight Vector2D
├─ ball.py # Ball entity, physics & trail
├─ paddle.py # Paddle entity, player/AI logic & effects
├─ particles.py # Particle & Star classes
├─ powerups.py # PowerUp entity & visuals
└─ storage.py # load/save high scores (JSON)
Menu
1→ Play vs Computer2→ Play vs Human3→ High ScoresE / M / H→ Change difficultyESC→ Quit
Gameplay
- Player 1 (Right): Arrow
↑/↓ - Player 2 (Left, only in Human vs Human):
W/S SPACE→ Pause / Resume
-
Difficulty
- The AI paddle behavior changes based on
Difficulty(EASY / MEDIUM / HARD). - You can toggle it from the menu using
E,M, orH. - To change the default, set
self.difficultyingame.py.
- The AI paddle behavior changes based on
-
Power-ups
- Speed Boost – temporarily increases ball speed.
- Paddle Grow / Shrink – temporarily changes paddle size.
- Shield – gives a paddle a one-time protective barrier.
- Multi-Ball – spawns an additional ball.
- Freeze – briefly pauses ball/paddle updates.
Power-ups spawn periodically and are collected when the ball collides with them. Particle bursts and highlights indicate pickups.
This project is licensed under the MIT License. See the LICENSE file for details.
Questions or feedback or want to collaborate? Reach out via my
LinkedIn: Brejesh Balakrishnan
