Skip to content

Latest commit

ย 

History

36 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

es

๐Ÿƒ Memory Game - Soccer Edition

Python Pygame Type Pairs License Version

A fully functional Soccer-themed Memory Card Game developed with Pygame. This project demonstrates video game programming concepts including grid layouts, event handling, state management, and interactive game mechanics.


๐ŸŽฌ Preview

Soccer Cards Preview

๐Ÿ‘จโ€๐ŸŽ“ Developer Info


๐ŸŽฎ Game Description

This is a classic Memorama game featuring soccer team logos. Players must find matching card pairs by flipping two at a time. The game includes:

  • Grid layout with 8 cards (4 pairs) arranged in a 2ร—4 grid
  • Card flip mechanics with smooth reveal animations
  • Pair detection system for matched cards
  • Auto-hide functionality for non-matching pairs
  • Win detection when all pairs are found
  • Card randomization for replayability
  • Interactive start button to begin new games

๐ŸŽฏ Game Mechanics

Controls

Control Action
Mouse Click Select and flip cards
Start Button Begin a new game with shuffled cards

Objective

Find all 4 soccer team card pairs by remembering their positions. Cards flip back if they don't match.

Game Rules

  1. Click the "Start Game" button to begin
  2. Click any card to reveal it
  3. Click a second card to try to find a match
  4. If the cards match, they stay revealed
  5. If they don't match, they flip back after 1 second
  6. Continue until all pairs are found
  7. The game resets automatically when you win

๐Ÿš€ Features

โœจ Core Game Features

  • Card Grid System: 2ร—4 grid layout with 4 unique soccer team logos
  • Pair Detection: Automatic comparison of selected cards
  • Timed Reveal: Unmatched cards hide after 1 second
  • Win Condition: Automatic win detection and game reset
  • Card Shuffle: Random positions at game start
  • State Management: Tracking of revealed and discovered cards

๐ŸŽจ Visual Elements

  • Soccer Team Logos: PSG, Real Madrid, Barcelona, and Inter Milan
  • Card Back Design: Clean grey design for hidden cards
  • Border Highlight: Black borders around each card
  • Start Button: Green button that turns white during gameplay
  • Smooth Rendering: 60 FPS gameplay

๐ŸŽฎ Interactive Elements

  • Click Detection: Precise mouse position tracking
  • Button States: Visual feedback for the start button
  • Card States: Three states (hidden, shown, discovered)
  • Turn Lock: Prevents clicks during card comparison

๐Ÿ”ง Technical Implementation

Game Architecture

# Main Components:
1. Card Class (Object-Oriented Design)
2. Screen Setup (Pygame Window)
3. Grid Layout System (2D Array)
4. Event Handling Loop
5. State Management

Data Structures

# Card states
hidden    โ†’ Grey rectangle (not yet flipped)
shown     โ†’ Team logo visible (being compared)
discovered โ†’ Team logo permanently visible (matched)

# Game states
not_started โ†’ Waiting for start button
playing     โ†’ Active game session
won         โ†’ All pairs found, auto-reset

Key Algorithms

Card Shuffle

Random Shuffle Algorithm:
- Generate random positions for all 8 cards
- Swap cards to randomize placement
- Guarantees fair distribution each game

Timed Hide Logic

Delayed Hide Mechanic:
- Record time.time() when second card is flipped
- Check elapsed time each frame
- Hide after 1 second if no match
- Non-blocking implementation

๐ŸŽจ Visual Design

Color Palette

Element Color Hex
Background White #FFFFFF
Card Back Grey #CECECE
Card Border Black #000000
Start Button (Active) Green #00FF00
Start Button (Playing) White #FFFFFF
Button Text Dynamic White/Grey by state

Card States

  1. Hidden: Grey rectangle with black border
  2. Shown: Team logo visible
  3. Discovered: Team logo permanently visible

๐Ÿ“Š System Requirements

Component Requirement
OS Windows 7 / 8 / 10 / 11
RAM 2 GB
Storage ~50 MB free space
Dependencies None โ€” bundled in executable

๐Ÿ“ฅ Download & Run

Quick Start โ€” No Installation!

The game is available as an executable โ€” no Python or dependencies required.

  1. Download the .exe from Releases
  2. Double-click the .exe file
  3. Play immediately โ€” no setup or configuration needed!

๐Ÿ› Known Limitations

  • Fixed window size of 800ร—450 (not resizable)
  • Only 4 card pairs (8 total)
  • No scoring system or timer
  • No difficulty levels

๐Ÿ“š Learning Outcomes

This project serves as an educational resource for understanding fundamental video game development concepts:

๐ŸŽ“ What You'll Learn

  1. Object-Oriented Programming

    • Class design and encapsulation
    • Instance attributes and methods
    • Object state management
    • Type hints and validation
  2. Pygame Fundamentals

    • Window and display setup
    • Event loop architecture
    • Mouse input handling
    • Surface and image rendering
    • Rectangle-based collision detection
  3. Grid Game Logic

    • 2D array manipulation
    • Coordinate system conversion
    • Grid traversal algorithms
    • Position-to-index mapping
  4. State Management

    • Game state tracking (not started, playing, won)
    • Card state machines (hidden, shown, discovered)
    • Turn-based logic implementation
    • Boolean flags for game control
  5. Event-Driven Programming

    • Mouse click event handling
    • Event processing pipeline
    • Button interaction logic
  6. Timing and Delays

    • Time-based mechanics with time.time()
    • Delayed card hiding
    • Frame rate control with clock.tick()
    • Non-blocking delay implementation
  7. Randomization Algorithms

    • Card shuffling techniques
    • Random position generation
    • Fair distribution guarantee
  8. Game Loop Design

    • Rendering loop structure
    • Update and render separation
    • FPS management
    • Continuous game state updates
  9. Collision Detection

    • Point-rectangle collision (collidepoint)
    • Grid boundary validation
    • Click area detection
  10. Visual Rendering

    • Image loading and blitting
    • Rectangle drawing
    • Text rendering
    • Layered rendering order

๐ŸŽฏ Skills Developed

By studying and modifying this code, you'll gain hands-on experience with:

โœ… Game design patterns and architecture
โœ… Memory management in memorama-style games
โœ… User interface design for grid-based games
โœ… Input validation and error handling
โœ… Algorithm implementation (shuffling, matching)
โœ… Code organization with classes and functions

This repository is perfect for students learning Pygame, video game development fundamentals, or anyone interested in understanding how classic memory games work programmatically.


๐Ÿค Contributions

Students and developers are welcome to:

  • Report bugs
  • Suggest new features or themes
  • Submit pull requests with improvements
  • Share gameplay strategies
  • Add new card themes

๐Ÿ“„ License

This project is educational in nature and available for free use for learning purposes. Soccer team logos are property of their respective owners and are used for educational purposes only.


๐Ÿ“ง Contact

Carlos Gabriel Magallanes Lรณpez
Email: cgmagallanes23@gmail.com


โญ If you enjoyed this game or found it educational, give it a star on GitHub!

๐ŸŽฎ Have fun playing!

About

A fully functional football-themed memory card game, developed with Pygame, Python.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages