This project is a simple implementation of the classic Pong game, created for learning Python syntax, Object-Oriented Programming (OOP) concepts, and practicing Git/GitHub workflows.
The architecture follows a Clean Architecture-style separation to keep the codebase modular, testable, and easy to maintain.
Here’s the layout of the project to keep things tidy and modular:
.
├── config
├── domain
│ └── models
├── interface
└── use_case
This is where you store all the game’s settings, like:
- The size of the game window (width and height)
- How fast the ball moves
- Colors for the ball, paddles, and background
- Frames per second (FPS) for smooth gameplay
This folder holds the core "objects" of the game, called entities. You’ll create two main classes:
- Ball 🎾
- Tracks its position (
x,y) and speed (dx,dy) - Moves around and bounces off walls
- Resets to the center after a point is scored
- Tracks its position (
- Paddle 🏓
- Moves up and down based on player input or a simple AI
- Keeps track of its position on the screen
This is the part that makes the game come to life visually! It handles:
- Drawing the ball, paddles, and score on the screen using pygame
- Listening for keyboard inputs (like arrow keys to move paddles)
- Showing the current score
This is where the game’s logic lives. It’s responsible for:
- Checking if the ball hits a paddle or goes out of bounds
- Updating the score when someone scores
- Resetting the game after a point
- Supporting Player vs Player or Player vs AI modes
Ready to play? Here’s how to run the game:
- Install pygame:
pip install pygame
- Run the main script:
python main.py