Welcome to the Python Games Collection repository! This project contains implementations of classic games in Python, using Pygame for an interactive and fun experience. Each game is contained within its own folder, complete with the main game code, unit tests, and detailed instructions for playing. Whether you’re looking to enjoy these classic games or learn from their code, this collection has something for everyone!
Python-Games-Collection/
│
├── GuessTheNumber/
│ ├── GuessTheNumber.py # Main code for the Guess The Number game
│ ├── test_GuessTheNumber.py # Unit tests for the Guess The Number game
│ └── README.md # Documentation for the Guess The Number game
│
├── Pong/
│ ├── Pong.py # Main code for the Pong game
│ ├── test_Pong.py # Unit tests for the Pong game
│ └── README.md # Documentation for the Pong game
│
├── Snake/
│ ├── Snake.py # Main code for the Snake game
│ ├── test_Snake.py # Unit tests for the Snake game
│ └── README.md # Documentation for the Snake game
│
├── TicTacToe/
│ ├── TicTacToe.py # Main code for the Tic Tac Toe game
│ ├── test_TicTacToe.py # Unit tests for the Tic Tac Toe game
│ └── README.md # Documentation for the Tic Tac Toe game
│
├── SpaceInvaders/
│ ├── SpaceInvaders.py # Main code for the Space Invaders game
│ ├── test_SpaceInvaders.py # Unit tests for the Space Invaders game
│ └── README.md # Documentation for the Space Invaders game
│
├── 2048/
│ ├── 2048.py # Main code for the 2048 game
│ ├── test_2048.py # Unit tests for the 2048 game
│ └── README.md # Documentation for the 2048 game
│
├── MemoryGame/
│ ├── Memory.py # Main code for the Memory game
│ ├── test_Memory.py # Unit tests for the Memory game
│ └── README.md # Documentation for the Memory game
│
└── README.md # Global documentation for the repository
A number guessing game where the player tries to guess a randomly generated number within a range. The game provides hints after each guess, indicating if the target number is "Higher" or "Lower" than the player's guess. Features include:
- Customizable range for the target number
- Feedback on each guess: "Higher", "Lower", or "Correct!"
- Keeps track of the number of attempts
See the Guess The Number README
A classic two-player game where each player controls a paddle, and the objective is to hit the ball past the opponent’s paddle to score points. Features include:
- Player-controlled paddle with arrow keys
- AI-controlled opponent paddle
- Ball bouncing off walls and paddles
- Score display
A single-player game where the player controls a snake that grows each time it eats food. The objective is to avoid colliding with the snake’s own body or the boundaries. Features include:
- Growing snake with each food item eaten
- Increasing difficulty as the snake grows
- Boundary and self-collision detection
- Score display
A two-player game (played on the same screen) where the objective is to be the first player to align three of your symbols in a row, column, or diagonal. Features include:
- 3x3 grid display
- Turn-based gameplay for two players
- Win and draw detection
- Console-based interface for simplicity
A classic arcade game where you control a spaceship and try to defend against waves of invading enemies. Destroy as many enemies as you can, earn points, and survive for as long as possible. Features include:
- Player-controlled spaceship that can shoot bullets
- Waves of enemies that move in formation and drop down as they reach screen edges
- Score tracking and lives system
- Game Over detection
A puzzle game where the objective is to combine tiles with the same value to reach the elusive 2048 tile. Slide the tiles, combine matching numbers, and try to reach the highest score! Features include:
- 4x4 grid with sliding and combining mechanics
- Random tile generation after each move
- Score tracking and win/lose conditions
- Reset option to start a new game
A classic memory card game where the objective is to find all matching pairs of cards on a 4x4 grid. Flip the cards, try to remember their positions, and match all pairs to win the game! Features include:
- Flip and match mechanics with 1-second delay for unmatched pairs
- 4x4 grid with 8 unique pairs, randomly shuffled
- Game completion detection with a congratulatory message
Each game requires:
- Python 3.6 or higher
- Pygame library (for all games except Guess The Number and Tic Tac Toe)
To install Pygame, run:
pip install pygame
-
Clone the repository:
git clone https://github.com/yourusername/Python-Games-Collection.git cd Python-Games-Collection
-
Navigate to the desired game folder:
cd Pong # or cd Snake, cd TicTacToe, cd GuessTheNumber, etc.
-
Run the game:
python Pong.py # or python Snake.py, python TicTacToe.py, etc.
-
To run the tests:
python -m unittest test_Pong.py # or test_Snake.py, test_TicTacToe.py, etc.
Contributions to improve these games or add features are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/new-feature
). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for more details.
Enjoy playing and exploring these classic games with Python! 🎉