A Python-based card game created using Pygame, featuring regular and special cards, score tracking, and game logic for both human and computer players.
Two players (you vs the computer) take turns playing cards from their hands. Points are awarded when matching colored cards are played, with bonuses for repeating numbers and various special cards that affect the flow. The player with the highest score at the end wins!
- Intuitive Pygame-based GUI
- Regular and 4 types of special cards (
Wild,Watcher,Colorstorm,Ascendancy) - Shuffle deck using Fisher-Yates algorithm
- Dynamic draw stack and discard pile
- AI randomly selects a card to play
- Card selection, play button interaction, and result display
- Bonus point logic and state tracking across rounds
- Game over detection and replay option
- Background music for improved game experience
pygame– For rendering GUI and handling game eventsrandom,sys,os,time– For core game mechanics and utilities
All libraries are standard or commonly used and are applied with efficiency in mind.
-
Fisher-Yates Shuffle Algorithm
Ensures fairness in card distribution through an in-place shuffle (shuffle()function). -
Round Resolution & Scoring Algorithm
Compares cards based on game rules, awards points, applies bonus logic, and transitions states accordingly (resolve_round()). -
Card Selection & Collision Detection
Mouse click detection and collision rectangles allow accurate card selection and game interactions (handle_card_selection()).
-
List– Used for managing:- Player and computer hands
- Draw stack
- Discard pile
-
Class–Cardclass used for encapsulating card properties and rendering logic, supporting multiple card types.
The program uses two or more standard data structures (Lists, Classes) and leverages them effectively to support game logic and rendering.
- Follows PEP8 style guide
- Accurate variable names (e.g.,
player_score,game_state,played_card_message) - All functions/classes include clear docstrings and consistent formatting
- Modularized logic:
deal_cards(),draw_player_hand(),play_selected_card(), etc.- Enables separation of concerns and better maintenance
-
Clone the repository using the command:
git clone https://github.com/aydinefendi/Python-Project.git
Then navigate into the project folder:cd Python-Project. -
Create a virtual environment:
- On macOS/Linux: use
python3 -m venv .venvand activate it withsource .venv/bin/activate. - On Windows: use
python -m venv .venvand activate it with.venv\Scripts\activate.
- On macOS/Linux: use
-
Install pygame manually using
pip install pygame -
Run the game with
python game.py.