Skip to content

A lightweight Pong game in Python (Pygame) with a main menu, configurable rounds/points, single-player AI, two-player mode, and sound effects.

Notifications You must be signed in to change notification settings

nands93/python_pong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Pong (Pygame)

A simple Pong game built with Pygame. It features a main menu, configuration screen, single-player (AI) and two-player modes, score/round tracking, and sound effects.

Features

  • Single-player mode (play against an AI) and two-player mode
  • Menu and configuration screens
  • Configurable match: points per round and rounds to win
  • Sound effects and basic visuals

Requirements

  • Python 3.8+
  • Pygame (pip install pygame)

Setup

# Optional: create and activate a virtual environment
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate

# Install dependency
pip install pygame

Run

python pong.py

This starts the app and opens the main menu from pong.menu. Use the mouse to select options.

Gameplay

  • 1 Player Mode: You control the left paddle; the right paddle is AI (see player.AutoPlayer).
  • 2 Players Mode: Both paddles are controlled by players.

Controls:

  • Player 1 (left): W (up), S (down)
  • Player 2 (right): Up Arrow (up), Down Arrow (down)

Configuration

From the configuration menu (opened via main menu), you can set:

  • ROUNDS: Number of rounds needed to win the match
  • POINTS: Points needed to win a round

A player wins a round upon reaching the selected points. The match ends when a player wins the selected number of rounds and the game returns to the main menu via pong.main.

Code Overview

Assets

All assets live under assets/:

Note: On case-sensitive filesystems the game uses the lowercase background file: assets/background.png.

Window & Performance

  • Default window size: 800x600 (see pong.main).
  • The main loop targets 60 FPS via pygame.time.Clock() in pong.main_game.

Troubleshooting

  • If audio initialization fails (e.g., no audio device), Pygame mixer may raise errors. As a workaround on headless systems:
    • Set an SDL audio driver (e.g., SDL_AUDIODRIVER=dummy) before running.
  • Ensure all files in the assets/ directory are present and readable.

License

No license specified.

About

A lightweight Pong game in Python (Pygame) with a main menu, configurable rounds/points, single-player AI, two-player mode, and sound effects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages