A visually stunning Blackjack card game built with Python and Tkinter, featuring realistic card graphics, smooth gameplay, and an intuitive user interface. Experience the thrill of 21 right on your desktop!
Challenge the dealer in this classic casino card game! Get as close to 21 as possible without going over, and beat the dealer's hand to win. Perfect for both casual players and those looking to practice their Blackjack strategy.
- Authentic Blackjack Rules: Standard casino rules including dealer stands on 17
- Visual Card Display: High-quality PNG card images for immersive gameplay
- Smart Ace Handling: Automatic ace value adjustment (11 or 1) to prevent busting
- Dealer AI: Realistic dealer behavior following traditional house rules
- Hidden Card Mechanic: Dealer's second card remains hidden until the showdown
- Stunning Card Graphics: Professional card images for all 52 cards in the deck
- Real-time Score Display: Live score tracking for both player and dealer
- Responsive Layout: Clean, organized interface with separate frames for each hand
- Card Rank Labels: Easy identification of card values
- Dynamic Updates: Smooth transitions as cards are dealt and revealed
- Full 52-Card Deck: Complete standard deck with all suits (Hearts, Diamonds, Clubs, Spades)
- Proper Shuffling: Randomized deck shuffle at the start of each game
- Instant Win Detection: Automatic detection of busts, wins, and ties
- Easy Controls: Simple three-button interface (Hit, Stand, New Game)
- Python 3.6 or higher
- Tkinter (usually comes pre-installed with Python)
- Card image assets in PNG format
-
Clone the repository
git clone https://github.com/NeonWest/BlackJack-Game.git cd BlackJack-Game -
Ensure you have the card images
- Create a folder named
PNG-cards/ - Place all 52 card images in this folder
- Images should be named:
{rank}_of_{suit}.png - Example:
ace_of_hearts.png,10_of_spades.png
- Create a folder named
-
Run the game
python blackjack.py
- Objective: Get closer to 21 than the dealer without going over
- Card Values:
- Number cards (2-10): Face value
- Face cards (J, Q, K): Worth 10 points
- Aces: Worth 11 points (automatically becomes 1 if needed to prevent bust)
- Hit: Draw another card to increase your hand value
- Stand: Keep your current hand and let the dealer play
- New Game: Start a fresh round with a newly shuffled deck
- Game starts with both you and the dealer receiving 2 cards
- Dealer's second card is hidden
- Choose to Hit (draw more cards) or Stand (end your turn)
- If you bust (go over 21), you lose immediately
- When you stand, the dealer reveals their hidden card
- Dealer must hit until reaching 17 or higher
- Winner is determined by who has the higher hand without busting
- ✅ You Win: Your score is higher than dealer's (without busting) OR dealer busts
- ❌ You Lose: You bust OR dealer's score is higher than yours
- 🤝 Tie: Both you and dealer have the same score
Object-Oriented Card System
# Deck representation using tuples
deck = [(rank, suit) for rank in ranks for suit in suits]
# Smart hand value calculation with ace handling
def hand_value(hand):
# Automatically adjusts ace values to prevent busting
while value > 21 and aces:
value -= 10
aces -= 1Image Caching System
# Efficient image loading and caching
card_photo_images = {} # Prevents redundant image loading
resized_image = original_image.subsample(scale_factor, scale_factor)Dynamic UI Updates
- Frames are rebuilt on each update for clean state management
- Conditional rendering for hidden dealer card
- Real-time score calculations
📁 BlackJack-Game/
├── 📄 blackjack.py # Main game logic and GUI
├── 📁 PNG-cards/ # Card image assets
│ ├── 2_of_hearts.png
│ ├── ace_of_spades.png
│ └── ... (all 52 cards)
└── 📄 README.md # This file
Modify the scale_factor variable to change card dimensions:
scale_factor = 3 # Higher = smaller cards, Lower = larger cardsSimply replace the PNG files in the PNG-cards/ folder while maintaining the naming convention:
{rank}_of_{suit}.png
- Clean Separation of Concerns: Logic, UI, and game state are well-organized
- Global State Management: Efficient handling of deck and hand states
- Event-Driven Architecture: Button callbacks control game flow
- Resource Management: Smart image caching prevents memory bloat
- Error Handling: Graceful handling of missing images and edge cases
Potential features for future versions:
- 💰 Betting system with chip management
- 📊 Win/loss statistics tracking
- 🎵 Sound effects for card dealing and wins
- 🏆 Achievement system
- 👥 Multiplayer support
- 💾 Save/load game state
- 🎨 Multiple card deck themes
Contributions are welcome! Areas for improvement:
- Additional card deck designs
- Enhanced UI/UX features
- Game rule variations (Spanish 21, Double Exposure, etc.)
- Performance optimizations
- Bug fixes and improvements
This project is open source and available for educational and personal use.
Omar Atakishiyev
- GitHub: @NeonWest
- Built with Python's Tkinter for cross-platform compatibility
- Implements authentic casino Blackjack rules
- Designed for both beginners learning Python and card game enthusiasts
This project demonstrates:
- ✅ Python GUI development with Tkinter
- ✅ Event-driven programming
- ✅ State management in games
- ✅ Image handling and optimization
- ✅ Game logic implementation
- ✅ Object-oriented programming principles
🎰 Ready to play? Clone the repo and try your luck at 21!
⭐ Enjoyed the game? Give it a star on GitHub!