This project is my first attempt at creating an executable (.exe) file from a Python script, showcasing various programming skills for my portfolio. Before this project, I had no experience in converting Python code into an executable format. The inspiration came from a childhood memory of playing a similar game that left a lasting impression, and I wanted to recreate that enjoyable experience.
The Train Color Matching Game is where players match trains of the same colour. Features include:
- Multiple game states (Menu, Playing, Game Over)
- Light/dark theme options
- Interactive buttons with hover effects
- Dynamic background elements (trees, clouds, stars)
- Python programming fundamentals
- Pygame library implementation
- Particle effect systems
- State management
- UI/UX design
- File handling and resource management
- Python: Core programming language
- Pygame: Game development library
- PyInstaller: Executable creation tool
To convert the Python script into an executable file, I used the following steps:
- Install PyInstaller: A tool for converting Python applications into standalone executables.
pip install pyinstaller
- Generate the Executable: Run PyInstaller with the script.
pyinstaller --onefile train_color_matcher.py
- Distribute the Executable: The generated
.exe
file can be found in thedist
directory and can be shared with others.
- Start the game by clicking the "Start Game" button
- Match the train colours from left to right
- Click on the coloured train at the bottom that matches the leftmost train on the track
- Score points for correct matches
- The game ends when all trains are matched
- Mouse Click: Select trains and interact with buttons
- Theme Toggle: Switch between light and dark modes
- Mute Button: Toggle sound effects and background music
- Particle System: Creates visual effects when buttons are clicked
- Dynamic Background:
- Moving clouds in both themes
- Twinkling stars in dark mode
- Decorative trees for the environment
- Main Classes:
ModernGame
: Main game controllerTrain
: Train object with movement and renderingModernButton
: Enhanced button with hover effectsParticle
: Visual effect system
- Train movement animations
- Button hover effects
- Particle effects
- Cloud movement
- Star twinkling (dark mode)
- Light and dark theme support
- Dynamic UI element adaptation
- Smooth theme transitions
- Theme-specific visual effects