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
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
display: flex;
|
| 16 |
+
flex-direction: column;
|
| 17 |
+
align-items: center;
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
background: linear-gradient(45deg, #1a1a1a, #2d2d2d);
|
| 20 |
+
font-family: 'Segoe UI', sans-serif;
|
| 21 |
+
color: #fff;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.game-container {
|
| 25 |
+
padding: 2rem;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.controls {
|
| 29 |
+
display: flex;
|
| 30 |
+
gap: 2rem;
|
| 31 |
+
margin-bottom: 2rem;
|
| 32 |
+
align-items: center;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.stats {
|
| 36 |
+
background: rgba(255, 255, 255, 0.1);
|
| 37 |
+
padding: 1rem 2rem;
|
| 38 |
+
border-radius: 10px;
|
| 39 |
+
font-size: 1.2rem;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
select {
|
| 43 |
+
padding: 0.5rem 1rem;
|
| 44 |
+
border-radius: 5px;
|
| 45 |
+
background: #3a3a3a;
|
| 46 |
+
color: #fff;
|
| 47 |
+
border: none;
|
| 48 |
+
cursor: pointer;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.grid {
|
| 52 |
+
display: grid;
|
| 53 |
+
gap: 1rem;
|
| 54 |
+
perspective: 1000px;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.card {
|
| 58 |
+
width: 100px;
|
| 59 |
+
height: 100px;
|
| 60 |
+
position: relative;
|
| 61 |
+
transform-style: preserve-3d;
|
| 62 |
+
transition: transform 0.6s;
|
| 63 |
+
cursor: pointer;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.card.flipped {
|
| 67 |
+
transform: rotateY(180deg);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.card-front, .card-back {
|
| 71 |
+
position: absolute;
|
| 72 |
+
width: 100%;
|
| 73 |
+
height: 100%;
|
| 74 |
+
backface-visibility: hidden;
|
| 75 |
+
display: flex;
|
| 76 |
+
align-items: center;
|
| 77 |
+
justify-content: center;
|
| 78 |
+
font-size: 2rem;
|
| 79 |
+
border-radius: 10px;
|
| 80 |
+
box-shadow: 0 0 10px rgba(0,0,0,0.3);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.card-front {
|
| 84 |
+
background: linear-gradient(135deg, #4a90e2, #357abd);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.card-back {
|
| 88 |
+
background: white;
|
| 89 |
+
transform: rotateY(180deg);
|
| 90 |
+
color: #333;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.matched {
|
| 94 |
+
animation: match 0.5s ease-in-out;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
@keyframes match {
|
| 98 |
+
0%, 100% { transform: scale(1) rotateY(180deg); }
|
| 99 |
+
50% { transform: scale(1.1) rotateY(180deg); }
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
button {
|
| 103 |
+
padding: 0.5rem 1rem;
|
| 104 |
+
border: none;
|
| 105 |
+
border-radius: 5px;
|
| 106 |
+
background: #4a90e2;
|
| 107 |
+
color: white;
|
| 108 |
+
cursor: pointer;
|
| 109 |
+
transition: background 0.3s;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
button:hover {
|
| 113 |
+
background: #357abd;
|
| 114 |
+
}
|
| 115 |
+
</style>
|
| 116 |
+
</head>
|
| 117 |
+
<body>
|
| 118 |
+
<div class="game-container">
|
| 119 |
+
<div class="controls">
|
| 120 |
+
<div class="stats">
|
| 121 |
+
<span>Score: <span id="score">0</span></span>
|
| 122 |
+
<span style="margin-left: 1rem">Time: <span id="timer">0:00</span></span>
|
| 123 |
+
</div>
|
| 124 |
+
<select id="difficulty">
|
| 125 |
+
<option value="easy">Easy (4x4)</option>
|
| 126 |
+
<option value="medium">Medium (6x6)</option>
|
| 127 |
+
<option value="hard">Hard (8x8)</option>
|
| 128 |
+
</select>
|
| 129 |
+
<button id="newGame">New Game</button>
|
| 130 |
+
</div>
|
| 131 |
+
<div class="grid" id="grid"></div>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<script>
|
| 135 |
+
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 136 |
+
|
| 137 |
+
const createSound = (frequency, type = 'sine') => {
|
| 138 |
+
const oscillator = audioContext.createOscillator();
|
| 139 |
+
const gainNode = audioContext.createGain();
|
| 140 |
+
oscillator.type = type;
|
| 141 |
+
oscillator.frequency.value = frequency;
|
| 142 |
+
oscillator.connect(gainNode);
|
| 143 |
+
gainNode.connect(audioContext.destination);
|
| 144 |
+
return { oscillator, gainNode };
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
const playSound = (frequency, duration = 0.1) => {
|
| 148 |
+
const sound = createSound(frequency);
|
| 149 |
+
sound.gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
|
| 150 |
+
sound.oscillator.start();
|
| 151 |
+
sound.oscillator.stop(audioContext.currentTime + duration);
|
| 152 |
+
};
|
| 153 |
+
|
| 154 |
+
class MemoryGame {
|
| 155 |
+
constructor() {
|
| 156 |
+
this.grid = document.getElementById('grid');
|
| 157 |
+
this.scoreElement = document.getElementById('score');
|
| 158 |
+
this.timerElement = document.getElementById('timer');
|
| 159 |
+
this.difficultySelect = document.getElementById('difficulty');
|
| 160 |
+
this.newGameBtn = document.getElementById('newGame');
|
| 161 |
+
|
| 162 |
+
this.cards = [];
|
| 163 |
+
this.flippedCards = [];
|
| 164 |
+
this.matchedPairs = 0;
|
| 165 |
+
this.score = 0;
|
| 166 |
+
this.timer = 0;
|
| 167 |
+
this.timerInterval = null;
|
| 168 |
+
|
| 169 |
+
this.setupEventListeners();
|
| 170 |
+
this.startNewGame();
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
setupEventListeners() {
|
| 174 |
+
this.newGameBtn.addEventListener('click', () => this.startNewGame());
|
| 175 |
+
this.difficultySelect.addEventListener('change', () => this.startNewGame());
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
startNewGame() {
|
| 179 |
+
this.grid.innerHTML = '';
|
| 180 |
+
this.cards = [];
|
| 181 |
+
this.flippedCards = [];
|
| 182 |
+
this.matchedPairs = 0;
|
| 183 |
+
this.score = 0;
|
| 184 |
+
this.scoreElement.textContent = '0';
|
| 185 |
+
clearInterval(this.timerInterval);
|
| 186 |
+
this.timer = 0;
|
| 187 |
+
this.updateTimer();
|
| 188 |
+
|
| 189 |
+
const difficulty = this.difficultySelect.value;
|
| 190 |
+
const size = difficulty === 'easy' ? 4 : difficulty === 'medium' ? 6 : 8;
|
| 191 |
+
|
| 192 |
+
this.grid.style.gridTemplateColumns = `repeat(${size}, 100px)`;
|
| 193 |
+
|
| 194 |
+
const pairs = (size * size) / 2;
|
| 195 |
+
const symbols = this.generateSymbols(pairs);
|
| 196 |
+
this.createCards(symbols);
|
| 197 |
+
|
| 198 |
+
this.startTimer();
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
generateSymbols(pairs) {
|
| 202 |
+
const emojis = ['๐จ', '๐ฎ', '๐ฒ', '๐ญ', '๐ช', '๐จ', '๐ฏ', '๐ฑ', '๐ณ', '๐ผ',
|
| 203 |
+
'๐ต', '๐น', '๐บ', '๐ธ', '๐ป', '๐ฌ', '๐ค', '๐ง', '๐', '๐',
|
| 204 |
+
'๐', '๐', '๐ฝ', '๐ฅ', '๐บ', '๐ท', '๐ธ', '๐น', '๐ผ', '๐',
|
| 205 |
+
'๐', '๐', '๐', '๐', '๐ซ', '๐ ', '๐ก', '๐ข'];
|
| 206 |
+
|
| 207 |
+
const selectedEmojis = [...emojis].sort(() => Math.random() - 0.5).slice(0, pairs);
|
| 208 |
+
return [...selectedEmojis, ...selectedEmojis].sort(() => Math.random() - 0.5);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
createCards(symbols) {
|
| 212 |
+
symbols.forEach((symbol, index) => {
|
| 213 |
+
const card = document.createElement('div');
|
| 214 |
+
card.className = 'card';
|
| 215 |
+
card.innerHTML = `
|
| 216 |
+
<div class="card-front">?</div>
|
| 217 |
+
<div class="card-back">${symbol}</div>
|
| 218 |
+
`;
|
| 219 |
+
card.addEventListener('click', () => this.flipCard(card, symbol));
|
| 220 |
+
this.grid.appendChild(card);
|
| 221 |
+
this.cards.push(card);
|
| 222 |
+
});
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
flipCard(card, symbol) {
|
| 226 |
+
if (this.flippedCards.length === 2 || card.classList.contains('flipped') ||
|
| 227 |
+
card.classList.contains('matched')) return;
|
| 228 |
+
|
| 229 |
+
card.classList.add('flipped');
|
| 230 |
+
playSound(440);
|
| 231 |
+
|
| 232 |
+
this.flippedCards.push({ card, symbol });
|
| 233 |
+
|
| 234 |
+
if (this.flippedCards.length === 2) {
|
| 235 |
+
this.checkMatch();
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
checkMatch() {
|
| 240 |
+
const [card1, card2] = this.flippedCards;
|
| 241 |
+
|
| 242 |
+
if (card1.symbol === card2.symbol) {
|
| 243 |
+
setTimeout(() => {
|
| 244 |
+
card1.card.classList.add('matched');
|
| 245 |
+
card2.card.classList.add('matched');
|
| 246 |
+
playSound(880, 0.2);
|
| 247 |
+
this.matchedPairs++;
|
| 248 |
+
this.score += 10;
|
| 249 |
+
this.scoreElement.textContent = this.score;
|
| 250 |
+
|
| 251 |
+
if (this.matchedPairs === this.cards.length / 2) {
|
| 252 |
+
this.endGame();
|
| 253 |
+
}
|
| 254 |
+
}, 500);
|
| 255 |
+
} else {
|
| 256 |
+
setTimeout(() => {
|
| 257 |
+
card1.card.classList.remove('flipped');
|
| 258 |
+
card2.card.classList.remove('flipped');
|
| 259 |
+
playSound(220, 0.2);
|
| 260 |
+
this.score = Math.max(0, this.score - 5);
|
| 261 |
+
this.scoreElement.textContent = this.score;
|
| 262 |
+
}, 1000);
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
this.flippedCards = [];
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
startTimer() {
|
| 269 |
+
this.timerInterval = setInterval(() => {
|
| 270 |
+
this.timer++;
|
| 271 |
+
this.updateTimer();
|
| 272 |
+
}, 1000);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
updateTimer() {
|
| 276 |
+
const minutes = Math.floor(this.timer / 60);
|
| 277 |
+
const seconds = this.timer % 60;
|
| 278 |
+
this.timerElement.textContent =
|
| 279 |
+
`${minutes}:${seconds.toString().padStart(2, '0')}`;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
endGame() {
|
| 283 |
+
clearInterval(this.timerInterval);
|
| 284 |
+
setTimeout(() => {
|
| 285 |
+
alert(`Congratulations! You won!\nScore: ${this.score}\nTime: ${this.timerElement.textContent}`);
|
| 286 |
+
}, 500);
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
new MemoryGame();
|
| 291 |
+
</script>
|
| 292 |
+
</body>
|
| 293 |
+
</html>
|