A feature-rich, full-screen Blackjack game built with Java Swing, featuring persistent game data, customizable settings, and an immersive gaming experience.
- Classic Blackjack Rules - Play traditional Blackjack against the dealer
- Full Betting System - Place bets with virtual chips ($5, $10, $25, $50)
- Clear Bet - Clear your current bet before dealing to adjust your wager
- Double Down - Double your bet and take exactly one more card
- Win Streaks - Track your consecutive wins
- Smart Dealer AI - Dealer behavior adapts to difficulty settings
- ๐ LAN Multiplayer - Play dealer vs player over local network(currently, this application feature is only working on two instances of a single PC)
- Persistent Chip Balance - Your chips are automatically saved and restored between sessions
- Virtual Chip Purchases - Buy more chips with test payment system
- Multiple Chip Packages:
- 50 chips - $5
- 100 chips - $10
- 250 chips - $20
- 500 chips - $35
- 1000 chips - $60
- 5000 chips - $250
- Test Card Support - Use the "Use Test Card" button to auto-fill valid test card details
- Starting Balance - Begin with 100 chips
- Out of Chips - When balance reaches $0, betting is disabled until chips are purchased
- Background Themes
- Default Dark Theme (free)
- Green Poker Table (purchasable with 150 chips)
- Animated Menu Background (purchasable with 200 chips)
- Custom Card Images - High-quality PNG card graphics
- Full-Screen Mode - Immersive, distraction-free gaming
-
Difficulty Levels
- Easy: Dealer hits on 16 or less
- Medium: Standard blackjack rules (hits on soft 17)
- Hard: Dealer plays optimally with soft hands
-
Luck Levels
- Normal: Standard blackjack odds
- Lucky: 10% bonus on wins, 15% chance to win on push
- Very Lucky: 25% bonus on wins, 25% chance to win on push, 10% chance bet is returned on loss
-
Audio Settings
- Sound Volume: Off / Low / Medium / High
- Background Music: On / Off
- Automatic Save System - Chips, purchases, and settings are saved automatically
- Database Storage - Uses properties file (
gamedata.properties) to store:- Current chip balance
- Owned backgrounds/themes
- Selected background
- Volume level
- Music on/off preference
- Difficulty level
- Luck level
-
Intuitive Controls
- Click-based betting system
- Clear status messages
- Real-time chip/bet/streak display
-
Visual Feedback
- Animated buttons with hover effects
- Color-coded stats (gold for chips, green for wins, red for bets)
- Card value display for both player and dealer
-
Menu System
- Main menu with game start, settings, and quit options
- Settings panel with scrollable options
- In-game menu button for quick navigation
- Sound Effects - Button clicks and game events with adjustable volume
- Button click sounds
- Bet placement sound
- Win celebration sound
- Loss sound
- Push/tie sound
- Background Music - Looping background music (toggle on/off)
- Volume Control - Four levels: Off, Low, Medium, High
- Persistent Settings - Audio preferences saved between sessions
- Audio Files (located in
src/data/audio/):click.wav- Button click sound effectbet.wav- Bet placement sound effectwin.wav- Win celebration sound effectlose.wav- Loss sound effectpush.wav- Push/tie sound effectbackground_music.wav- Background music loop
- ESC - Exit the application
- Host Game (Dealer) - Start a server and act as the dealer for another player
- Join Game (Player) - Connect to a dealer's server and play as a remote player
- Same-PC Testing - Currently works by running two instances on the same computer (use
localhostor127.0.0.1to connect) - Real-time Gameplay - All actions synchronized between dealer and player
- Server Info Display - Dealer can see their IP address for connection sharing
Note: Multiplayer is currently in beta. Chip balances in multiplayer mode are session-only and not saved to the database. For persistent chip tracking, use single-player mode.
- Start the Game - Click "Start Game" from the main menu
- Place Your Bet - Use the betting buttons ($5, $10, $25, $50) to place your bet
- Deal Cards - Click "Deal Cards" to start the round
- Make Your Move
- Hit - Take another card
- Stand - Keep your current hand
- Double Down - Double your bet and take one final card (available only with 2 cards)
- Win or Lose - Beat the dealer without going over 21
- Repeat - Place a new bet and play another round
Current Limitation: Multiplayer currently works best when running two instances on the same computer. Use
localhostor127.0.0.1as the IP address to connect.
- Click "Multiplayer" from the main menu
- Select "Host Game" - Server starts automatically on port 7777
- Note Your IP - Your IP address is displayed on screen (use
localhostfor same-PC testing) - Wait for Player - Game begins when a player connects
- Monitor Game - Watch the player's actions and dealer responses in real-time
- View Logs - Server activity logged in the bottom panel
- Click "Multiplayer" from the main menu
- Select "Join Game" and enter the dealer's IP address (use
localhostfor same-PC testing) - Connect - Wait for connection confirmation
- Place Bets - Use betting buttons like in single-player mode
- Play Cards - Hit, Stand, or Double Down as usual
- Results - Chips updated based on game outcome (session-only, not saved)
- Blackjack - Get 21 with your first two cards (pays 3:2 + luck bonus)
- Higher Hand - Beat the dealer's hand without busting (pays 2:1 + luck bonus)
- Dealer Bust - Dealer goes over 21 (pays 2:1 + luck bonus)
- Push - Tie with the dealer (bet returned, possible luck bonus)
- Java 8 or higher
- Display resolution: 1024x768 or higher (recommended for full-screen)
- Operating System: Windows, macOS, or Linux
src/
โโโ data/
โ โโโ Card.java - Card data model (Serializable)
โ โโโ Rank.java - Card rank enum with values
โ โโโ Suit.java - Card suit enum
โ โโโ ChipsDatabase.java - Persistent storage handler
โ โโโ audio/ - Audio files folder
โ โ โโโ click.wav - Button click sound
โ โ โโโ bet.wav - Bet placement sound
โ โ โโโ win.wav - Win celebration sound
โ โ โโโ lose.wav - Loss sound
โ โ โโโ push.wav - Push/tie sound
โ โ โโโ background_music.wav - Background music
โ โโโ images/ - Image files folder
โ โโโ logo.png - Game logo
โ โโโ PNG-cards-1.3/ - Playing card images
โ โโโ First_Background.png
โ โโโ Second_Background.webp
โ โโโ Third_Background.png
โโโ logic/
โ โโโ Deck.java - Deck management and shuffling
โ โโโ Hand.java - Hand calculation and blackjack logic
โโโ network/
โ โโโ GameMessage.java - Network message protocol (Serializable)
โ โโโ GameServer.java - Server (dealer) networking logic
โ โโโ GameClient.java - Client (player) networking logic
โโโ ui/
โโโ BlackjackGUI.java - Main game interface
โโโ MultiplayerDialog.java - Multiplayer mode selection
โโโ MultiplayerServerGUI.java - Dealer server interface
โโโ MultiplayerClientGUI.java - Player client interface
โโโ RedButton.java - Custom styled button
โโโ AnimatedBackgroundPanel.java - Animated menu background
โโโ CardImages.java - Card image loading and caching
โโโ PaymentDialog.java - Virtual chip purchase interface
โโโ AudioManager.java - Audio playback and volume control
โโโ UIConstants.java - Centralized UI constants
โโโ GraphicsUtil.java - Graphics utility methods
- Separation of Concerns - Data, logic, and UI are separated into distinct packages
- No Code Repetition - Utility classes eliminate duplicate code
- Enum-Based Design - Card ranks and suits use enums with display methods
- Helper Methods - Dialog helpers and graphics utilities reduce boilerplate
- TCP Sockets - Reliable connection between dealer and player
- Object Serialization - Game state transmitted as serializable objects
- Message Protocol - Comprehensive GameMessage class handles all game events
- Threaded I/O - Non-blocking network communication
- Real-time Sync - Card deals, bets, and results synchronized instantly
- Default Port - Uses port 7777
- Current Status - Beta feature, tested with same-PC instances using localhost
- Image Caching - Card images are cached to prevent redundant loading
- Efficient Rendering - Graphics2D with antialiasing for smooth visuals
- Lazy Loading - Resources loaded only when needed
- Immediate Feedback - Real-time updates to chips, bets, and game state
- Error Prevention - Buttons disabled when actions aren't available
- Persistent State - Game state automatically saved after every change
# Compile all files
javac -d bin src/**/*.java
# Run single player game
java -cp bin ui.BlackjackGUI
# Run multiplayer server (dealer)
java -cp bin ui.MultiplayerServerGUI
# Run multiplayer client (player) - replace <server-ip> with dealer's IP
java -cp bin ui.MultiplayerClientGUI <server-ip>Open the project in your favorite Java IDE and run BlackjackGUI.java
Developed as a final project for SE1course.
Educational project
Note: This game uses test payment cards for demonstration purposes. No real money or payment processing is involved.
