A fully-featured implementation of the classic UNO card game built with Python and Pygame. This game features smooth animations, visual effects, sound, AI opponents with varying difficulty levels, and follows official UNO rules.
Vaclav Dlabac (alias Dlaby)
This project was created at their request for educational purposes. It serves as a demonstration of game development principles using Python and Pygame, showcasing object-oriented programming, event-driven architecture, and game AI implementation.
- Official UNO Rules: Complete implementation of standard UNO gameplay mechanics
- Multiplayer Support: Play against 1-3 computer opponents (named Player 2, Player 3, Player 4)
- AI Difficulty Levels: Three bot difficulty levels (Easy, Medium, Hard)
- Turn-Based Gameplay: Clear turn indicators and game flow
- Special Cards: All UNO special cards including Skip, Reverse, Draw 2, Wild, and Wild Draw 4
- Card Animations: Smooth card movement when drawing from deck and playing to discard pile
- Splash Effects: Dynamic 10-frame animations when cards hit the table
- Different effects for normal cards vs wild cards
- Effects render behind cards for realistic depth
- Face-down Draw Animation: Cards remain hidden during draw animation for privacy
- Visual Feedback: Yellow glow for current player, green outline for playable cards
- Sound Effects: Card drawing and playing sounds
- Supports WAV and MP3 formats (currently using CARD.mp3)
- Volume control set to 20% for comfortable gameplay
- Main Menu System: Easy navigation with game setup options
- In-Game UI: Clean, intuitive interface showing:
- Current player's hand with hover effects
- Opponent card counts and positions
- Deck and discard pile with labels
- Current game state and turn indicator
- Pause Menu: Pause mid-game with ESC key
- Game History Panel: Track recent moves on the right side (1100x800 game window)
- Color Selection: Interactive color picker overlay for wild cards
- Custom Card Rendering: Composite rendering system combining:
- Color bases for each card color
- Number/symbol overlays
- Professional card back design
- Smooth scaling for different card sizes
- Responsive Design:
- Menu: 800x800 square window
- Game: 1100x800 with history panel
- Visual Effects: Smooth animations and transitions
- Python 3.7 or higher
- pip (Python package installer)
-
Clone or download the repository:
git clone https://github.com/Dlaby23/PyGameWorkshop.git cd PyGameWorkshop -
Create a virtual environment (recommended):
python -m venv venv # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the game:
python main.py
- Launch the game by running
python main.py - From the main menu, click "Play"
- Select the number of bot opponents (1-3) using +/- buttons
- Click "Start Game"
- Mouse: Click on cards to play them, navigate menus
- ESC: Pause/unpause the game
- Click Deck: Draw a card when you can't play
- Objective: Be the first player to get rid of all your cards
- Basic Play:
- Match the top card of the discard pile by color or number
- Play special cards to affect gameplay
- Draw a card if you can't play
- Cards with green outline are playable
- Special Cards:
- Skip: Next player loses their turn
- Reverse: Changes the direction of play
- Draw 2: Next player draws 2 cards and loses their turn
- Wild: Choose any color to continue play
- Wild Draw 4: Choose color AND next player draws 4 cards
- Winning: First player to play all their cards wins
- Save Wild cards for when you're stuck
- Use action cards strategically to disrupt opponents
- Pay attention to opponents' card counts
- Try to empty your hand of high-value cards first
PyGameWorkshop/
├── main.py # Main game entry point
├── requirements.txt # Python dependencies
├── README.md # This file
├── .gitignore # Git ignore rules
│
├── Assets/ # Game assets
│ ├── EFFECTS/ # Animation sprites
│ │ ├── NORMAL CARD/ # 10-frame splash for normal cards (tile000-009.png)
│ │ └── WILD CARD/ # 10-frame splash for wild cards (tile143-152.png)
│ ├── SOUNDS/ # Sound effects
│ │ └── CARD.mp3 # Card draw/play sound
│ ├── *.png # Card symbols and numbers
│ ├── *_base.png # Color base cards
│ ├── back.png # Card back design
│ ├── background.png # Game background
│ ├── deck.png # Deck placeholder
│ └── logo.png # Game logo
│
├── game/ # Core game logic
│ ├── __init__.py
│ ├── bot.py # AI bot implementation with 3 difficulty levels
│ ├── card.py # Card class with animation support
│ ├── deck.py # Deck management
│ ├── game_state.py # Game state and history management
│ └── player.py # Player base class
│
├── ui/ # User interface components
│ ├── __init__.py
│ ├── buttons.py # Button and ColorButton components
│ ├── game_ui.py # In-game UI with effects integration
│ └── menu.py # Menu systems (Main, Pause, Game Setup)
│
├── utils/ # Utility modules
│ ├── __init__.py
│ ├── assets.py # Asset loading and card composite rendering
│ ├── constants.py # Game constants and settings
│ ├── effects.py # Sprite animation system for card effects
│ └── sounds.py # Sound effects manager
│
└── test_effects.py # Effect animation test utility
- MVC Pattern: Separation of game logic, UI, and control flow
- State Management: Clear game states (Menu, Playing, Paused, Game Over)
- Event-Driven: Pygame event system for user input
- Modular Design: Organized into logical modules for maintainability
- Game State: Manages current game status, player turns, and rules
- Card System:
- Composite rendering for dynamic card generation
- Animation system with easing functions
- Position tracking to prevent rendering glitches
- AI System: Three difficulty levels with different strategies:
- Easy: Random valid moves
- Medium: Basic strategy, prefers high-value cards
- Hard: Advanced strategy considering opponent hands
- UI System:
- Layered rendering with menu systems and in-game HUD
- History panel for tracking game events
- Responsive layout adaptation
- Animation System:
- Efficient sprite sheet handling
- Frame-based animation with proper timing
- Support for multiple simultaneous effects
- Sound System:
- Automatic sound loading
- Integrated with all card actions
- Efficient sprite management using subsurfaces
- Optimized card rendering using composite images
- Frame rate limited to 60 FPS for smooth gameplay
- Sprite sheets pre-loaded and cached
Run the effects test to preview animations:
python test_effects.py- Left Click: Play normal card effect at mouse position
- Right Click: Play wild card effect at mouse position
- Press 1: Normal effect at center
- Press 2: Wild effect at center
The codebase is structured to make adding new features straightforward:
- New card types: Modify
card.pyand add assets - New game modes: Extend
game_state.py - UI improvements: Update components in
ui/directory - New effects: Add sprite sheets to
Assets/EFFECTS/ - New sounds: Add audio files to
Assets/SOUNDS/
- PEP 8 compliant Python code
- Clear docstrings for all classes and methods
- Logical file organization
- Consistent naming conventions
- Type hints where beneficial
- Added smooth card animations for drawing and playing
- Implemented 10-frame splash effects when cards hit the table
- Different effects for normal vs wild cards
- Added sound effects for all card actions
- Fixed card position glitches (0,0 flash bug)
- Improved bot naming (Player 2, 3, 4 instead of Bot 1, 2, 3)
- Enhanced visual feedback and UI polish
-
Game won't start:
- Ensure Python 3.7+ is installed
- Check all dependencies are installed via
pip install -r requirements.txt - Verify all asset files are present in the Assets/ directory
-
No sound:
- Check Assets/SOUNDS/ contains CARD.mp3 or CARD.wav
- Ensure volume is not muted
- Pygame supports WAV and MP3, but not M4A/MP4
-
Graphics issues:
- Update Pygame to the latest version
- Check display drivers are up to date
-
Performance problems:
- Close other applications
- Effects are optimized but may impact older systems
- Author: Vaclav Dlabac (alias Dlaby)
- Purpose: Educational project demonstrating game development with Python/Pygame
- Framework: Python 3.9+ with Pygame 2.6+
- Game Design: Classic UNO card game by Mattel
- Implementation: Custom Python/Pygame implementation
- Assets: Custom created for this implementation
This is an educational implementation created at the request of Unicorn University for educational and learning purposes. UNO is a trademark of Mattel, Inc. This project is not affiliated with or endorsed by Mattel, Inc.
Enjoy playing UNO with animations and sound!
