Skip to content

sristyanand00/game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Overview This documentation outlines the structure, functionality, and logic of the Memory Game, a simple browser-based card matching game using HTML, CSS, and JavaScript. The goal of the game is to match pairs of emoji cards by flipping them. HTML Structure Elements:

  1. Container (

    ): Holds the game title, game board, and reset button.

  2. Game Board (

    ): Placeholder for the card grid dynamically populated by JavaScript.

  3. Reset Button (): Refreshes the page to restart the game. JavaScript Functionality Key Components

  4. Emoji Array An array containing pairs of emojis to serve as the cards in the game.

  5. Shuffle Function Randomly rearranges the emoji array to ensure different card placements in every game.

  6. Card Generation Creates a grid of

    elements representing cards. Each card is assigned a hidden emoji via the data-emoji attribute.

  7. Card Click Handler Clicking a card reveals its emoji. A boxOpen class is added to track flipped cards.

  8. Matching Logic Compares the inner HTML of the two flipped cards. If they match, a boxMatch class is added to mark them as matched. If all pairs are matched, the player wins.

  9. Resetting Unmatched Cards If the flipped cards don't match, they are flipped back after a delay.

  10. Game Reset Button Reloads the browser window, resetting the game.

Additional Functions:

checkForMatch() Checks if two selected cards match.

disableCards() Disables interaction with matched cards.

unflipCards() Resets the state of unmatched cards.

resetBoard() Resets internal variables for card tracking.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published