A Python implementation of the classic Columns puzzle game using Pygame. Players control falling columns consisting of three colored blocks and attempt to create matches of three or more blocks of the same color horizontally, vertically, or diagonally.
The project also includes an automated replay mode that reads moves from an input file and reproduces gameplay step by step.
-
🎮 Real-time gameplay using Pygame
-
🧩 Falling columns of three colored blocks
-
⬅️➡️ Horizontal movement
-
🔄 Column rotation
-
✨ Match detection in four directions:
- Vertical
- Horizontal
- Diagonal (↘)
- Diagonal (↗)
-
⬇️ Gravity simulation after blocks are removed
-
🏆 Score tracking
-
📄 Input-file-based replay mode
-
A column containing three colored blocks falls from the top of the board.
-
The player can:
- Move the column left
- Move the column right
- Rotate the order of colors
- Drop the column faster
-
Whenever three or more blocks of the same color are aligned, they are removed.
-
After blocks are removed, the remaining blocks fall due to gravity.
-
The game continues until no more columns can be placed.
| Key | Action |
|---|---|
| Left Arrow | Move left |
| Right Arrow | Move right |
| Space | Rotate colors |
| Down Arrow | Accelerate falling |
| S | Pause/Resume |
| Q | Quit |
| Esc | Quit |
The repository includes a replay system that reads actions from an input file.
Example:
CCH
Left
Left
Rotate
FREEZE
CGH
Right
FREEZE
CCA
FREEZE
Where:
CCH,CGH,CCArepresent newly generated columnsLeftmoves the column leftRightmoves the column rightRotatechanges the order of colorsFREEZEdrops and locks the column in place
This mode can be used for:
- Testing
- Demonstrations
- Automated gameplay reproduction
- Debugging
.
├── column.py
├── column2.py
├── input.txt
└── README.md
- Python 3.x
- Pygame
Install dependencies:
pip install pygamepython column.pypython column2.pyThe program reads commands from input.txt and reproduces the game automatically.
The game is implemented using:
- Matrix-based board representation
- Collision detection
- Pattern matching algorithms
- Gravity simulation
- Event-driven programming with Pygame
- File-based action replay
This project was developed as an educational exercise in:
- Python programming
- Object-oriented and event-driven design
- Matrix and grid manipulation
- Game logic implementation
- Algorithmic problem solving using Pygame
Parham Hassan