Skip to content

Space Ping Pong is a neon, arcade-style 2D pong game built with Python + Pygame. Play vs computer (E/M/H) or local two-player. Includes power-ups, particle effects, starfield, screen shake, and persistent high scores. Modular codebase (ball/paddle/powerups/game) easy to extend.

License

Notifications You must be signed in to change notification settings

brej-29/space-ping-pong

Repository files navigation

🛰️ Space Ping Pong

An arcade-style, neon space-themed ping pong game built with Python & Pygame

Space Ping Pong gameplay


Built with the tools and technologies:

Python | Pygame | dataclasses | Enum | JSON (local storage) | OOP

Table of Contents


Overview

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.


Project Highlights

  • 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.

Features

  • 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.

Getting Started

Follow these steps to set up and run the project on your machine.

Prerequisites

  • Python 3.8+
  • pip (Python package manager)

Installation

  1. Clone the repository (or download the source code):

    git clone https://github.com/brej-29/space-ping-pong.git
    cd <repo-name>
  2. Install dependencies:

pip install -r requirements.txt

Configuration

This 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).

Usage

Run the game from the project root:

python main.py

If you’re using a virtual environment, activate it first (see above).


Project Structure

.
├─ 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)

Controls

Menu

  • 1 → Play vs Computer
  • 2 → Play vs Human
  • 3 → High Scores
  • E / M / H → Change difficulty
  • ESC → Quit

Gameplay

  • Player 1 (Right): Arrow /
  • Player 2 (Left, only in Human vs Human): W / S
  • SPACE → Pause / Resume

Difficulty & Power-ups

  • Difficulty

    • The AI paddle behavior changes based on Difficulty (EASY / MEDIUM / HARD).
    • You can toggle it from the menu using E, M, or H.
    • To change the default, set self.difficulty in game.py.
  • 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.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

Questions or feedback or want to collaborate? Reach out via my
LinkedIn: Brejesh Balakrishnan

About

Space Ping Pong is a neon, arcade-style 2D pong game built with Python + Pygame. Play vs computer (E/M/H) or local two-player. Includes power-ups, particle effects, starfield, screen shake, and persistent high scores. Modular codebase (ball/paddle/powerups/game) easy to extend.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages