forked from kunjgit/GameZone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b128c19
commit 119b299
Showing
7 changed files
with
258 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Recall Rush | ||
|
||
Recall Rush is a memory card game where players flip cards to find matching pairs. The game is built using HTML, CSS, and JavaScript, providing a user-friendly interface with a timer, move counter, and a reset button. | ||
|
||
## Features | ||
|
||
- **Dynamic Card Generation**: The cards are dynamically generated and shuffled for each game. | ||
- **Timer**: Keeps track of the time taken to complete the game. | ||
- **Move Counter**: Counts the number of moves made by the player. | ||
- **Reset Button**: Allows the player to reset the game at any time. | ||
- **Smooth Animations**: Provides a visually appealing experience with flip animations. | ||
- **Responsive Design**: The game is responsive and can be played on both desktop and mobile devices. | ||
- **Gradient Color Theme**: Utilizes a gradient color theme for a vibrant look. | ||
|
||
## Game Logic | ||
|
||
1. The game board consists of 16 cards, with 8 unique values, each appearing twice. | ||
2. Players click on a card to flip it and reveal its value. | ||
3. The goal is to find all matching pairs of cards with the least number of moves. | ||
4. If two cards match, they remain flipped. If not, they are flipped back over after a short delay. | ||
5. The game ends when all pairs are found. | ||
|
||
## Getting Started | ||
|
||
To run the game locally: | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/your-username/recall-rush.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Recall Rush</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="game-container"> | ||
<div class="header"> | ||
<h1>Recall Rush</h1> | ||
<div class="stats"> | ||
<div id="timer">Time: 0</div> | ||
<div id="moves">Moves: 0</div> | ||
</div> | ||
</div> | ||
<div class="game-board" id="game-board"> | ||
<!-- Cards will be dynamically generated here --> | ||
</div> | ||
<button id="reset-btn">Reset</button> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
const gameBoard = document.getElementById('game-board'); | ||
const timerDisplay = document.getElementById('timer'); | ||
const movesDisplay = document.getElementById('moves'); | ||
const resetBtn = document.getElementById('reset-btn'); | ||
|
||
let cards = []; | ||
let firstCard, secondCard; | ||
let hasFlippedCard = false; | ||
let lockBoard = false; | ||
let moves = 0; | ||
let timer; | ||
let seconds = 0; | ||
|
||
const cardValues = ['A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F', 'G', 'G', 'H', 'H']; | ||
|
||
// Shuffle the card values | ||
cardValues.sort(() => 0.5 - Math.random()); | ||
|
||
function createBoard() { | ||
cardValues.forEach(value => { | ||
const card = document.createElement('div'); | ||
card.classList.add('card'); | ||
card.dataset.value = value; | ||
|
||
const frontFace = document.createElement('div'); | ||
frontFace.classList.add('front'); | ||
frontFace.textContent = value; | ||
|
||
const backFace = document.createElement('div'); | ||
backFace.classList.add('back'); | ||
backFace.textContent = '?'; | ||
|
||
card.appendChild(frontFace); | ||
card.appendChild(backFace); | ||
|
||
card.addEventListener('click', flipCard); | ||
gameBoard.appendChild(card); | ||
cards.push(card); | ||
}); | ||
} | ||
|
||
function flipCard() { | ||
if (lockBoard || this === firstCard) return; | ||
this.classList.add('flip'); | ||
|
||
if (!hasFlippedCard) { | ||
hasFlippedCard = true; | ||
firstCard = this; | ||
} else { | ||
hasFlippedCard = false; | ||
secondCard = this; | ||
checkForMatch(); | ||
} | ||
} | ||
|
||
function checkForMatch() { | ||
if (firstCard.dataset.value === secondCard.dataset.value) { | ||
disableCards(); | ||
} else { | ||
unflipCards(); | ||
} | ||
moves++; | ||
movesDisplay.textContent = `Moves: ${moves}`; | ||
} | ||
|
||
function disableCards() { | ||
firstCard.removeEventListener('click', flipCard); | ||
secondCard.removeEventListener('click', flipCard); | ||
resetBoard(); | ||
} | ||
|
||
function unflipCards() { | ||
lockBoard = true; | ||
setTimeout(() => { | ||
firstCard.classList.remove('flip'); | ||
secondCard.classList.remove('flip'); | ||
resetBoard(); | ||
}, 1500); | ||
} | ||
|
||
function resetBoard() { | ||
[hasFlippedCard, lockBoard] = [false, false]; | ||
[firstCard, secondCard] = [null, null]; | ||
} | ||
|
||
function startTimer() { | ||
timer = setInterval(() => { | ||
seconds++; | ||
timerDisplay.textContent = `Time: ${seconds}`; | ||
}, 1000); | ||
} | ||
|
||
function resetGame() { | ||
clearInterval(timer); | ||
timer = null; | ||
seconds = 0; | ||
moves = 0; | ||
timerDisplay.textContent = `Time: ${seconds}`; | ||
movesDisplay.textContent = `Moves: ${moves}`; | ||
cards.forEach(card => { | ||
card.classList.remove('flip'); | ||
card.addEventListener('click', flipCard); | ||
}); | ||
cards = []; | ||
gameBoard.innerHTML = ''; | ||
setTimeout(createBoard, 500); | ||
startTimer(); | ||
} | ||
|
||
resetBtn.addEventListener('click', resetGame); | ||
|
||
// Start the game | ||
createBoard(); | ||
startTimer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
background: #f8f9fa; | ||
} | ||
|
||
.game-container { | ||
text-align: center; | ||
} | ||
|
||
.header { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.stats { | ||
display: flex; | ||
justify-content: center; | ||
gap: 20px; | ||
font-size: 20px; | ||
} | ||
|
||
.game-board { | ||
display: grid; | ||
grid-template-columns: repeat(4, 100px); | ||
grid-template-rows: repeat(4, 100px); | ||
gap: 10px; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.card { | ||
width: 100px; | ||
height: 100px; | ||
background: linear-gradient(135deg, #ffa726, #ff7043); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 40px; | ||
color: white; | ||
cursor: pointer; | ||
border-radius: 10px; | ||
position: relative; | ||
transform-style: preserve-3d; | ||
transition: transform 0.5s; | ||
} | ||
|
||
.card.flip { | ||
transform: rotateY(180deg); | ||
} | ||
|
||
.card .front, | ||
.card .back { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
backface-visibility: hidden; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 10px; | ||
} | ||
|
||
.card .back { | ||
transform: rotateY(180deg); | ||
background: white; | ||
color: #ffa726; | ||
font-size: 40px; | ||
} | ||
|
||
#reset-btn { | ||
margin-top: 20px; | ||
padding: 10px 20px; | ||
font-size: 16px; | ||
background: linear-gradient(135deg, #ff7043, #ffa726); | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters