Skip to content

beiyen/react-memory-game

Repository files navigation

Memory Game

Description

The Memory Game is a simple card-matching game built with React. The objective of the game is to select each card only once. This project demonstrates the use of useState and useEffect.

Features

  • Fetches 12 random card data from the Pokémon TCG API on each game start.
  • Shuffles the cards randomly for every point.
  • Tracks the player's score.
  • Creates a new game when a card is clicked twice.

Installation

  1. Clone the repository:
    git clone https://github.com/bienlim/memory-game.git
  2. Navigate to the project directory:
    cd memory-game
  3. Install the dependencies:
    npm install

Usage

  1. Start the development server:
    npm run dev
  2. Open your browser and navigate to http://localhost:5173/.

Code Overview

Components

  • Game.jsx: The main component that handles the game logic, including fetching card data, shuffling cards, and managing the game state.

State Management

  • useState: Used to manage the score, high score, selected cards, and the deck of cards.
  • useEffect: Used to fetch card data from the Pokémon TCG API when the component mounts and update the Displayed High score.

Styling

  • TailwindCSS: Used for styling the application with utility-first CSS classes.

Build Tool

  • Vite: Used as the build tool for faster and leaner development experience.

API

This project uses the Pokémon TCG API to fetch card data.

Acknowledgements

About

A card-matching game built with React

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published