DC Memory Game is a browser-based memory matching game where players test their memory by flipping cards to find matching pairs of DC heroes. The game challenges players to match all pairs before running out of moves or time. At the end of the game, a score is calculated based on the number of successful matches and remaining moves or time. Players can restart the game to try and improve their score.
The game also features a hidden Easter Egg where DC heroes animate across the screen when the logo is clicked three times.
- Player selects a difficulty level: Easy, Normal, or Hard.
- The player clicks Start Game.
- The
#game-introscreen disappears, and#game-screenappears. - The
Gameclass creates the game board (cards), shuffles them, shows a 3-second preview, and starts the timer. - The player clicks on cards to flip them.
- Stats (Score, Moves, Time) update in real time.
- If two flipped cards match, the score increases; if not, the cards flip back and score decreases slightly.
- When all cards are matched or moves/time run out:
#game-screenhides.#game-endappears with the final score and a win/lose message.
- Players can Restart Game to reset everything and play again.
- Clicking the game logo three times triggers an Easter Egg animation with sound.
- Comic-style floating balloon messages show alerts like "No moves enough!" or "Time's Up!"
| Level | Moves | Time (s) |
|---|---|---|
| Easy | 24 | 80 |
| Normal | 20 | 60 |
| Hard | 16 | 50 |
The minimum features required for this DC Memory Game are:
- Start screen with game title and "Start Game" button.
- Game board displaying 12 cards (6 pairs of DC heroes) in a grid layout.
- Cards can be flipped to reveal the hero image.
- Matching pairs remain visible; non-matching pairs flip back automatically.
- Move counter that tracks the number of flips made.
- Timer counting down the remaining time.
- Score counter that increases when pairs are matched and decreases slightly when mismatched.
- Game over screen showing the final score and a message indicating whether the player won or lost.
- Restart button to replay the game.
- Easter Egg animation for extra fun.
These are features I can implement after completing the MVP:
- Make the game fully responsive for mobile and tablet devices.
- Include additional sound effects for card flips, matches, and game win/loss events.
- Add theme variations (different backgrounds or hero sets).
- Add more card pairs and heroes for increased difficulty.
- Implement a high-score leaderboard to track top scores.
- HTML
- CSS
- JavaScript
- DOM Manipulation
- Audio API
- CSS animations
The Game class manages a memory card game with character cards.
flippedCards— Array storing the currently flipped cards.score— Current player score.moves— Number of remaining moves.remainingTime— Remaining time on the timer.timerId— ID of the timer used withsetInterval.lockBoard— Boolean that temporarily locks the board.boardSound— Background board audio.boardSound.volume— Volume of the board sound.flipSound— Flip card sound.flipSound.volume— Volume of flip sound.loseSound— Sound for losing.loseSound.volume— Volume of lose sound.winSound— Sound for winning.winSound.volume— Volume of win sound.isSoundOn— Boolean toggle for sounds.characters— Array of hero names.gameCharacters— Duplicated and shuffled array of characters for gameplay.
Shuffles the gameCharacters array using the Durstenfeld shuffle algorithm.
Initializes the game board, creating HTML elements for the cards and adding click events.
Flips all cards for 3 seconds at the start of the game to show a preview.
Handles card click logic, managing moves and checking when two cards are flipped.
Checks if two flipped cards match, updates the score, unlocks cards, or ends the game.
Starts the game timer, decrementing remainingTime every second.
Ends the game, showing a victory or defeat screen and the final score.
Displays a comic-style balloon animation on the screen for 1 second with a custom message.
message— A string that will appear inside the balloon (e.g., "No moves enough!" or "Time's Up!").- The balloon floats upward in a comic vintage style, fading out as it rises.
- Used in
endGame()when the player runs out of moves or time to give visual feedback before showing the end screen. - Can be reused for other temporary alerts or messages during the game.
- Triggers the Easter Egg animation of DC heroes.
The EasterEgg class handles the animation of DC heroes across the intro screen when the game logo is clicked three times.
DcComicsHeroes— Array of hero names used in the Easter Egg (["batmanegg", "flashegg", "greenlanternegg", "shazanegg", "supermanegg","wonderwomanegg"]).clickSound— Audio object for click sound.clickSound.volume— Volume of click sound.directions— Array of direction objects{dx, dy}for hero animation.
shuffleDcComicsArray()— Shuffles theDcComicsHeroesarray using the Durstenfeld algorithm.DcComicsRuns()— Creates herodivelements dynamically, appends them to#game-intro, and animates them moving across the screen. Each hero moves according to its assigned direction and is removed when offscreen.
This script handles the game's start, restart, sound toggle, logo clicks, and UI interactions.
startButton— The "Start Game" button element.restartButton— The "Restart Game" button element.introScreen— The initial introduction screen element.gameScreen— The main game screen element.endScreen— The game over / victory screen element.imgLogo— Game logo element, used for Easter Egg.musicButton— Button to toggle sound/music.musicIcon— Image inside music button.introMusic— Intro music audio object.introMusic.volume— Volume of intro music.game— Instance of theGameclass.easterEgg— Instance ofEasterEgg.clickCount— Counts clicks on logo for Easter Egg.
startButton— Starts the game when clicked by callingstartGame().restartButton— Restarts the game when clicked by callingresetGame().musicButton— Toggles background and board music.imgLogo— Click to increment Easter Egg counter.
- Hides the intro screen and shows the game screen.
- Creates a new instance of
Game. - Updates the UI with initial
moves,score, andremainingTime. - Shuffles the cards, initializes the game board, shows a preview of all cards, and starts the timer.
- Handles sound playback depending on user toggle.
- Hides the end screen and shows the game screen.
- Calls the
restartGame()method on the currentGameinstance to reset the game state.
- Calls
DcComicsRuns()from theEasterEggclass.
The game has the following states (views):
-
Intro / Start Screen
- Shows the game logo, a start button, and a subtitle.
- Player clicks "Start Game" to transition to the Game Screen.
-
Game Screen
- Displays the game board, score, moves, and timer.
- Player flips cards to match pairs.
- The game can end in two ways:
- Victory: all pairs are matched.
- Defeat: moves run out or time expires.
- After the game ends, the state transitions to the End Screen.
-
End Screen
- Shows a final score and a message (e.g., "Congratulations!" or "Game Over").
- Player can click "Restart Game" to go back to the Game Screen and start a new game.
List of tasks in order of priority:
-
Set up project structure
- Create folders:
images,css,js,videos - Create files:
index.html,style.css,game.js,script.js,easteregg.js
- Create folders:
-
Design the HTML layout
- Intro screen with logo, start button, and subtitle.
- Game screen with stats (score, moves, timer) and game board.
- End screen with final score, message, and restart button.
-
Style the game using CSS
- Layout and positioning.
- Card dimensions, grid, and 3D flip animation.
- Intro and End screen styling.
- Responsive design adjustments.
-
Implement game logic in JavaScript
- Create
Gameclass. - Define properties (score, moves, timer, flipped cards, sounds).
- Initialize game board and shuffle cards.
- Handle card flipping and matching logic.
- Count moves and update stats.
- Detect victory or defeat.
- Implement Easter Egg animation.
- Create
-
Connect JS to HTML
- Add event listeners for Start, Restart buttons, music toggle, and Easter Egg.
- Update DOM elements (score, moves, time) dynamically.
-
Test the game
- Verify card flipping works correctly.
- Ensure moves and timer update properly.
- Check end game messages for win/lose.
- Confirm restart works as expected.
- Test Easter Egg animation.
-
Difficulty Levels
- Players can now select Easy, Normal, or Hard before starting.
- Each difficulty adjusts:
- Easy: 24 moves, 80 seconds.
- Normal: 20 moves, 60 seconds.
- Hard: 16 moves, 50 seconds.
-
Comic Balloon Notifications
- Shows messages like
"No moves enough!"or"Time's Up!"during gameplay. - Implemented with
showComicBalloon(message)ingame.js. - Floats upward in comic-style and fades out.
- Shows messages like
-
Game Preview
- At the start, all cards flip for 3 seconds to preview positions.
-
Sound Management
- Background and board music toggle correctly with the music button.
- Flip, win, and lose sounds play only if sound is enabled.
- Intro music pauses when gameplay starts.
-
Restart Game
- Restart button fully resets score, moves, timer, board, and sound states.
- Works with all difficulty levels and preserves sound settings.
-
Timer Adjustment
- Timer starts after the 3-second preview.
- Counts down every 1.2 seconds for sync with gameplay.
-
Easter Egg
- Clicking the logo 3 times triggers DC heroes animation with sound.





