Spaces:
Running
Running
undefined - Initial Deployment
Browse files- README.md +7 -5
- index.html +501 -19
- prompts.txt +0 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: game
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,501 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Color Memory Challenge</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.game-tile {
|
| 11 |
+
transition: all 0.3s ease;
|
| 12 |
+
transform-style: preserve-3d;
|
| 13 |
+
}
|
| 14 |
+
.game-tile.flipped {
|
| 15 |
+
transform: rotateY(180deg);
|
| 16 |
+
}
|
| 17 |
+
.game-tile-face {
|
| 18 |
+
backface-visibility: hidden;
|
| 19 |
+
position: absolute;
|
| 20 |
+
width: 100%;
|
| 21 |
+
height: 100%;
|
| 22 |
+
border-radius: 0.5rem;
|
| 23 |
+
display: flex;
|
| 24 |
+
justify-content: center;
|
| 25 |
+
align-items: center;
|
| 26 |
+
color: white;
|
| 27 |
+
font-weight: bold;
|
| 28 |
+
}
|
| 29 |
+
.game-tile-front {
|
| 30 |
+
background: linear-gradient(135deg, #374151, #6B7280);
|
| 31 |
+
}
|
| 32 |
+
.game-tile-back {
|
| 33 |
+
background: linear-gradient(135deg, #3B82F6, #1D4ED8);
|
| 34 |
+
transform: rotateY(180deg);
|
| 35 |
+
}
|
| 36 |
+
.game-tile.matched .game-tile-front {
|
| 37 |
+
opacity: 0.2;
|
| 38 |
+
}
|
| 39 |
+
.confetti {
|
| 40 |
+
position: absolute;
|
| 41 |
+
width: 10px;
|
| 42 |
+
height: 10px;
|
| 43 |
+
background-color: #f00;
|
| 44 |
+
border-radius: 50%;
|
| 45 |
+
}
|
| 46 |
+
@keyframes pulse {
|
| 47 |
+
0%, 100% { transform: scale(1); }
|
| 48 |
+
50% { transform: scale(1.05); }
|
| 49 |
+
}
|
| 50 |
+
.pulse-animation {
|
| 51 |
+
animation: pulse 1.5s infinite;
|
| 52 |
+
}
|
| 53 |
+
</style>
|
| 54 |
+
</head>
|
| 55 |
+
<body class="bg-gray-900 text-white min-h-screen flex flex-col items-center justify-center p-4">
|
| 56 |
+
<div class="max-w-4xl w-full">
|
| 57 |
+
<header class="text-center mb-8">
|
| 58 |
+
<h1 class="text-4xl md:text-5xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-purple-600 mb-2">
|
| 59 |
+
Color Memory Challenge
|
| 60 |
+
</h1>
|
| 61 |
+
<p class="text-gray-300 mb-4">Match all pairs of colors to win!</p>
|
| 62 |
+
<div class="flex justify-center items-center space-x-6 mb-4">
|
| 63 |
+
<div class="bg-gray-800 px-4 py-2 rounded-lg">
|
| 64 |
+
<span class="text-blue-400"><i class="fas fa-stopwatch mr-2"></i></span>
|
| 65 |
+
<span id="timer">00:00</span>
|
| 66 |
+
</div>
|
| 67 |
+
<div class="bg-gray-800 px-4 py-2 rounded-lg">
|
| 68 |
+
<span class="text-yellow-400"><i class="fas fa-star mr-2"></i></span>
|
| 69 |
+
<span id="moves">0</span> moves
|
| 70 |
+
</div>
|
| 71 |
+
<div class="bg-gray-800 px-4 py-2 rounded-lg">
|
| 72 |
+
<span class="text-purple-400"><i class="fas fa-brain mr-2"></i></span>
|
| 73 |
+
<span id="memory">100%</span> memory
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
+
<button id="start-game" class="bg-gradient-to-r from-green-500 to-emerald-600 hover:from-green-600 hover:to-emerald-700 text-white font-bold py-3 px-6 rounded-full shadow-lg transition-all duration-300 transform hover:scale-105">
|
| 77 |
+
<i class="fas fa-play mr-2"></i> Start Game
|
| 78 |
+
</button>
|
| 79 |
+
</header>
|
| 80 |
+
|
| 81 |
+
<div id="game-board" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3 sm:gap-4 mb-8"></div>
|
| 82 |
+
|
| 83 |
+
<div id="game-modal" class="fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50 hidden">
|
| 84 |
+
<div class="bg-gray-800 rounded-xl p-8 max-w-lg w-full mx-4 text-center transform transition-all duration-500 scale-0">
|
| 85 |
+
<div class="text-4xl mb-4 text-green-400"><i class="fas fa-trophy"></i></div>
|
| 86 |
+
<h2 class="text-3xl font-bold mb-2">You Won!</h2>
|
| 87 |
+
<p class="text-gray-300 mb-6">Congratulations on completing the challenge!</p>
|
| 88 |
+
<div class="grid grid-cols-2 gap-4 mb-6">
|
| 89 |
+
<div class="bg-gray-700 p-3 rounded-lg">
|
| 90 |
+
<p class="text-sm text-gray-400">Time</p>
|
| 91 |
+
<p class="text-xl font-bold" id="modal-time"></p>
|
| 92 |
+
</div>
|
| 93 |
+
<div class="bg-gray-700 p-3 rounded-lg">
|
| 94 |
+
<p class="text-sm text-gray-400">Moves</p>
|
| 95 |
+
<p class="text-xl font-bold" id="modal-moves"></p>
|
| 96 |
+
</div>
|
| 97 |
+
<div class="bg-gray-700 p-3 rounded-lg">
|
| 98 |
+
<p class="text-sm text-gray-400">Memory Usage</p>
|
| 99 |
+
<p class="text-xl font-bold" id="modal-memory"></p>
|
| 100 |
+
</div>
|
| 101 |
+
<div class="bg-gray-700 p-3 rounded-lg">
|
| 102 |
+
<p class="text-sm text-gray-400">Difficulty</p>
|
| 103 |
+
<p class="text-xl font-bold" id="modal-difficulty"></p>
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
+
<div class="flex justify-center gap-4">
|
| 107 |
+
<button id="play-again" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-full transition-all">
|
| 108 |
+
Play Again
|
| 109 |
+
</button>
|
| 110 |
+
<button id="close-modal" class="bg-gray-600 hover:bg-gray-700 text-white font-bold py-2 px-6 rounded-full transition-all">
|
| 111 |
+
Close
|
| 112 |
+
</button>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<footer class="mt-auto text-center text-gray-500 py-4 text-sm">
|
| 119 |
+
<p>© 2023 Color Memory Challenge | Built with <i class="fas fa-heart text-red-500"></i> using HTML, CSS & JavaScript</p>
|
| 120 |
+
</footer>
|
| 121 |
+
|
| 122 |
+
<script>
|
| 123 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 124 |
+
// Game state variables
|
| 125 |
+
let gameStarted = false;
|
| 126 |
+
let timerInterval;
|
| 127 |
+
let seconds = 0;
|
| 128 |
+
let moves = 0;
|
| 129 |
+
let memoryPercentage = 100;
|
| 130 |
+
let firstTile = null;
|
| 131 |
+
let secondTile = null;
|
| 132 |
+
let lockBoard = false;
|
| 133 |
+
let matchedPairs = 0;
|
| 134 |
+
let difficulty = 'medium';
|
| 135 |
+
let colorPairs = [];
|
| 136 |
+
let audioEnabled = true;
|
| 137 |
+
|
| 138 |
+
// DOM elements
|
| 139 |
+
const gameBoard = document.getElementById('game-board');
|
| 140 |
+
const startButton = document.getElementById('start-game');
|
| 141 |
+
const timerDisplay = document.getElementById('timer');
|
| 142 |
+
const movesDisplay = document.getElementById('moves');
|
| 143 |
+
const memoryDisplay = document.getElementById('memory');
|
| 144 |
+
const gameModal = document.getElementById('game-modal');
|
| 145 |
+
const modalTime = document.getElementById('modal-time');
|
| 146 |
+
const modalMoves = document.getElementById('modal-moves');
|
| 147 |
+
const modalMemory = document.getElementById('modal-memory');
|
| 148 |
+
const modalDifficulty = document.getElementById('modal-difficulty');
|
| 149 |
+
const playAgainButton = document.getElementById('play-again');
|
| 150 |
+
const closeModalButton = document.getElementById('close-modal');
|
| 151 |
+
|
| 152 |
+
// Color palettes for different difficulty levels
|
| 153 |
+
const colorPalettes = {
|
| 154 |
+
easy: [
|
| 155 |
+
'#FF5252', '#4CAF50', '#2196F3', '#FFC107',
|
| 156 |
+
'#9C27B0', '#00BCD4', '#E91E63', '#FF9800'
|
| 157 |
+
],
|
| 158 |
+
medium: [
|
| 159 |
+
'#FF5252', '#4CAF50', '#2196F3', '#FFC107',
|
| 160 |
+
'#9C27B0', '#00BCD4', '#E91E63', '#FF9800',
|
| 161 |
+
'#795548', '#607D8B', '#8BC34A', '#FF5722',
|
| 162 |
+
'#673AB7', '#009688', '#3F51B5', '#CDDC39'
|
| 163 |
+
],
|
| 164 |
+
hard: [
|
| 165 |
+
'#EF5350', '#66BB6A', '#42A5F5', '#FFA726',
|
| 166 |
+
'#AB47BC', '#26C6DA', '#EC407A', '#FF7043',
|
| 167 |
+
'#8D6E63', '#78909C', '#9CCC65', '#E57373',
|
| 168 |
+
'#7E57C2', '#26A69A', '#5C6BC0', '#DCE775',
|
| 169 |
+
'#FF5252', '#4CAF50', '#2196F3', '#FFC107',
|
| 170 |
+
'#9C27B0', '#00BCD4', '#E91E63', '#FF9800'
|
| 171 |
+
]
|
| 172 |
+
};
|
| 173 |
+
|
| 174 |
+
// Sounds
|
| 175 |
+
const sounds = {
|
| 176 |
+
flip: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-game-click-1114.mp3'),
|
| 177 |
+
match: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-unlock-game-notification-253.mp3'),
|
| 178 |
+
win: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-winning-chimes-2015.mp3'),
|
| 179 |
+
wrong: new Audio('https://assets.mixkit.co/sfx/preview/mixkit-retro-arcade-lose-2027.mp3')
|
| 180 |
+
};
|
| 181 |
+
|
| 182 |
+
// Initialize the game
|
| 183 |
+
function initGame() {
|
| 184 |
+
// Reset game state
|
| 185 |
+
gameStarted = false;
|
| 186 |
+
clearInterval(timerInterval);
|
| 187 |
+
seconds = 0;
|
| 188 |
+
moves = 0;
|
| 189 |
+
memoryPercentage = 100;
|
| 190 |
+
matchedPairs = 0;
|
| 191 |
+
firstTile = null;
|
| 192 |
+
secondTile = null;
|
| 193 |
+
lockBoard = false;
|
| 194 |
+
|
| 195 |
+
// Update displays
|
| 196 |
+
timerDisplay.textContent = '00:00';
|
| 197 |
+
movesDisplay.textContent = '0';
|
| 198 |
+
memoryDisplay.textContent = '100%';
|
| 199 |
+
|
| 200 |
+
// Determine difficulty based on screen width
|
| 201 |
+
const screenWidth = window.innerWidth;
|
| 202 |
+
if (screenWidth < 640) { // Mobile
|
| 203 |
+
difficulty = 'easy';
|
| 204 |
+
colorPairs = [...colorPalettes.easy, ...colorPalettes.easy];
|
| 205 |
+
} else if (screenWidth < 1024) { // Tablet
|
| 206 |
+
difficulty = 'medium';
|
| 207 |
+
colorPairs = [...colorPalettes.medium, ...colorPalettes.medium];
|
| 208 |
+
} else { // Desktop
|
| 209 |
+
difficulty = 'hard';
|
| 210 |
+
colorPairs = [...colorPalettes.hard, ...colorPalettes.hard];
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
// Shuffle the colors
|
| 214 |
+
colorPairs = shuffleArray(colorPairs);
|
| 215 |
+
|
| 216 |
+
// Clear and rebuild the game board
|
| 217 |
+
gameBoard.innerHTML = '';
|
| 218 |
+
|
| 219 |
+
// Create tiles
|
| 220 |
+
colorPairs.forEach((color, index) => {
|
| 221 |
+
const tile = document.createElement('div');
|
| 222 |
+
tile.classList.add('game-tile', 'cursor-pointer', 'aspect-square', 'relative');
|
| 223 |
+
tile.dataset.index = index;
|
| 224 |
+
tile.dataset.color = color;
|
| 225 |
+
|
| 226 |
+
const frontFace = document.createElement('div');
|
| 227 |
+
frontFace.classList.add('game-tile-face', 'game-tile-front');
|
| 228 |
+
frontFace.innerHTML = '<i class="fas fa-question text-2xl sm:text-3xl opacity-70"></i>';
|
| 229 |
+
|
| 230 |
+
const backFace = document.createElement('div');
|
| 231 |
+
backFace.classList.add('game-tile-face', 'game-tile-back');
|
| 232 |
+
backFace.style.backgroundColor = color;
|
| 233 |
+
backFace.innerHTML = `<div class="w-1/2 h-1/2 rounded-lg" style="background-color: ${color}; border: 2px solid white;"></div>`;
|
| 234 |
+
|
| 235 |
+
tile.appendChild(frontFace);
|
| 236 |
+
tile.appendChild(backFace);
|
| 237 |
+
|
| 238 |
+
tile.addEventListener('click', flipTile);
|
| 239 |
+
|
| 240 |
+
gameBoard.appendChild(tile);
|
| 241 |
+
});
|
| 242 |
+
|
| 243 |
+
// Update modal difficulty display
|
| 244 |
+
modalDifficulty.textContent = difficulty.charAt(0).toUpperCase() + difficulty.slice(1);
|
| 245 |
+
|
| 246 |
+
// Reset start button
|
| 247 |
+
startButton.innerHTML = '<i class="fas fa-play mr-2"></i> Start Game';
|
| 248 |
+
startButton.classList.remove('bg-gradient-to-r', 'from-red-500', 'to-red-600');
|
| 249 |
+
startButton.classList.add('bg-gradient-to-r', 'from-green-500', 'to-emerald-600', 'hover:from-green-600', 'hover:to-emerald-700');
|
| 250 |
+
|
| 251 |
+
// Show memory tiles briefly at start
|
| 252 |
+
if (gameStarted) {
|
| 253 |
+
showTilesBriefly();
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
// Shuffle array using Fisher-Yates algorithm
|
| 258 |
+
function shuffleArray(array) {
|
| 259 |
+
for (let i = array.length - 1; i > 0; i--) {
|
| 260 |
+
const j = Math.floor(Math.random() * (i + 1));
|
| 261 |
+
[array[i], array[j]] = [array[j], array[i]];
|
| 262 |
+
}
|
| 263 |
+
return array;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
// Start the game
|
| 267 |
+
function startGame() {
|
| 268 |
+
if (gameStarted) return;
|
| 269 |
+
|
| 270 |
+
gameStarted = true;
|
| 271 |
+
startButton.innerHTML = '<i class="fas fa-sync-alt mr-2"></i> Restart';
|
| 272 |
+
startButton.classList.remove('bg-gradient-to-r', 'from-green-500', 'to-emerald-600', 'hover:from-green-600', 'hover:to-emerald-700');
|
| 273 |
+
startButton.classList.add('bg-gradient-to-r', 'from-red-500', 'to-red-600', 'hover:from-red-600', 'hover:to-red-700');
|
| 274 |
+
|
| 275 |
+
// Start timer
|
| 276 |
+
seconds = 0;
|
| 277 |
+
updateTimer();
|
| 278 |
+
timerInterval = setInterval(() => {
|
| 279 |
+
seconds++;
|
| 280 |
+
updateTimer();
|
| 281 |
+
|
| 282 |
+
// Reduce memory percentage over time
|
| 283 |
+
if (seconds % 5 === 0 && memoryPercentage > 20) {
|
| 284 |
+
memoryPercentage -= 1;
|
| 285 |
+
memoryDisplay.textContent = `${memoryPercentage}%`;
|
| 286 |
+
}
|
| 287 |
+
}, 1000);
|
| 288 |
+
|
| 289 |
+
// Show tiles briefly at start
|
| 290 |
+
showTilesBriefly();
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// Update timer display
|
| 294 |
+
function updateTimer() {
|
| 295 |
+
const minutes = Math.floor(seconds / 60);
|
| 296 |
+
const remainingSeconds = seconds % 60;
|
| 297 |
+
timerDisplay.textContent = `${String(minutes).padStart(2, '0')}:${String(remainingSeconds).padStart(2, '0')}`;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
// Show all tiles briefly at game start
|
| 301 |
+
function showTilesBriefly() {
|
| 302 |
+
const tiles = document.querySelectorAll('.game-tile');
|
| 303 |
+
tiles.forEach(tile => tile.classList.add('flipped'));
|
| 304 |
+
|
| 305 |
+
setTimeout(() => {
|
| 306 |
+
tiles.forEach(tile => tile.classList.remove('flipped'));
|
| 307 |
+
}, 2000);
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
// Flip a tile
|
| 311 |
+
function flipTile() {
|
| 312 |
+
if (!gameStarted) {
|
| 313 |
+
startGame();
|
| 314 |
+
return;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
if (lockBoard || this.classList.contains('flipped') || this.classList.contains('matched')) {
|
| 318 |
+
return;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
// Play sound
|
| 322 |
+
if (audioEnabled) sounds.flip.play();
|
| 323 |
+
|
| 324 |
+
this.classList.add('flipped');
|
| 325 |
+
|
| 326 |
+
if (!firstTile) {
|
| 327 |
+
firstTile = this;
|
| 328 |
+
return;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
secondTile = this;
|
| 332 |
+
moves++;
|
| 333 |
+
movesDisplay.textContent = moves;
|
| 334 |
+
|
| 335 |
+
checkForMatch();
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
// Check if the flipped tiles match
|
| 339 |
+
function checkForMatch() {
|
| 340 |
+
const isMatch = firstTile.dataset.color === secondTile.dataset.color;
|
| 341 |
+
|
| 342 |
+
if (isMatch) {
|
| 343 |
+
disableTiles();
|
| 344 |
+
|
| 345 |
+
// Play match sound
|
| 346 |
+
if (audioEnabled) sounds.match.play();
|
| 347 |
+
|
| 348 |
+
matchedPairs++;
|
| 349 |
+
|
| 350 |
+
// Check if all pairs are matched
|
| 351 |
+
if (matchedPairs === colorPairs.length / 2) {
|
| 352 |
+
setTimeout(endGame, 500);
|
| 353 |
+
}
|
| 354 |
+
} else {
|
| 355 |
+
unflipTiles();
|
| 356 |
+
|
| 357 |
+
// Play wrong sound
|
| 358 |
+
if (audioEnabled) sounds.wrong.play();
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
// Disable matched tiles
|
| 363 |
+
function disableTiles() {
|
| 364 |
+
firstTile.classList.add('matched');
|
| 365 |
+
secondTile.classList.add('matched');
|
| 366 |
+
|
| 367 |
+
// Add some visual feedback
|
| 368 |
+
firstTile.classList.add('pulse-animation');
|
| 369 |
+
secondTile.classList.add('pulse-animation');
|
| 370 |
+
|
| 371 |
+
setTimeout(() => {
|
| 372 |
+
firstTile.classList.remove('pulse-animation');
|
| 373 |
+
secondTile.classList.remove('pulse-animation');
|
| 374 |
+
}, 1000);
|
| 375 |
+
|
| 376 |
+
resetBoard();
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
// Unflip tiles that don't match
|
| 380 |
+
function unflipTiles() {
|
| 381 |
+
lockBoard = true;
|
| 382 |
+
|
| 383 |
+
setTimeout(() => {
|
| 384 |
+
firstTile.classList.remove('flipped');
|
| 385 |
+
secondTile.classList.remove('flipped');
|
| 386 |
+
|
| 387 |
+
resetBoard();
|
| 388 |
+
}, 1000);
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
// Reset the board state
|
| 392 |
+
function resetBoard() {
|
| 393 |
+
[firstTile, secondTile] = [null, null];
|
| 394 |
+
lockBoard = false;
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
// End the game
|
| 398 |
+
function endGame() {
|
| 399 |
+
clearInterval(timerInterval);
|
| 400 |
+
|
| 401 |
+
// Play win sound
|
| 402 |
+
if (audioEnabled) sounds.win.play();
|
| 403 |
+
|
| 404 |
+
// Update modal with results
|
| 405 |
+
modalTime.textContent = timerDisplay.textContent;
|
| 406 |
+
modalMoves.textContent = moves;
|
| 407 |
+
modalMemory.textContent = `${memoryPercentage}%`;
|
| 408 |
+
|
| 409 |
+
// Show modal with animation
|
| 410 |
+
const modalContent = gameModal.querySelector('.transform');
|
| 411 |
+
gameModal.classList.remove('hidden');
|
| 412 |
+
setTimeout(() => {
|
| 413 |
+
modalContent.classList.remove('scale-0');
|
| 414 |
+
modalContent.classList.add('scale-100');
|
| 415 |
+
}, 50);
|
| 416 |
+
|
| 417 |
+
// Add confetti effect
|
| 418 |
+
createConfetti();
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
// Create confetti effect
|
| 422 |
+
function createConfetti() {
|
| 423 |
+
const colors = ['#f00', '#0f0', '#00f', '#ff0', '#f0f', '#0ff'];
|
| 424 |
+
const container = document.body;
|
| 425 |
+
|
| 426 |
+
for (let i = 0; i < 100; i++) {
|
| 427 |
+
const confetti = document.createElement('div');
|
| 428 |
+
confetti.classList.add('confetti');
|
| 429 |
+
|
| 430 |
+
// Random properties
|
| 431 |
+
const color = colors[Math.floor(Math.random() * colors.length)];
|
| 432 |
+
const size = Math.random() * 10 + 5;
|
| 433 |
+
const posX = Math.random() * window.innerWidth;
|
| 434 |
+
const delay = Math.random() * 3;
|
| 435 |
+
const duration = Math.random() * 3 + 2;
|
| 436 |
+
|
| 437 |
+
confetti.style.backgroundColor = color;
|
| 438 |
+
confetti.style.width = `${size}px`;
|
| 439 |
+
confetti.style.height = `${size}px`;
|
| 440 |
+
confetti.style.left = `${posX}px`;
|
| 441 |
+
confetti.style.top = '-10px';
|
| 442 |
+
confetti.style.zIndex = '1000';
|
| 443 |
+
|
| 444 |
+
// Animation
|
| 445 |
+
confetti.style.animation = `fall ${duration}s ease-in ${delay}s forwards`;
|
| 446 |
+
|
| 447 |
+
// Create keyframes dynamically
|
| 448 |
+
const keyframes = `
|
| 449 |
+
@keyframes fall {
|
| 450 |
+
to {
|
| 451 |
+
transform: translateY(${window.innerHeight + 10}px) rotate(${Math.random() * 360}deg);
|
| 452 |
+
opacity: 0;
|
| 453 |
+
}
|
| 454 |
+
}
|
| 455 |
+
`;
|
| 456 |
+
|
| 457 |
+
const style = document.createElement('style');
|
| 458 |
+
style.innerHTML = keyframes;
|
| 459 |
+
document.head.appendChild(style);
|
| 460 |
+
|
| 461 |
+
container.appendChild(confetti);
|
| 462 |
+
|
| 463 |
+
// Remove after animation
|
| 464 |
+
setTimeout(() => {
|
| 465 |
+
confetti.remove();
|
| 466 |
+
style.remove();
|
| 467 |
+
}, (duration + delay) * 1000);
|
| 468 |
+
}
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
// Event listeners
|
| 472 |
+
startButton.addEventListener('click', initGame);
|
| 473 |
+
playAgainButton.addEventListener('click', () => {
|
| 474 |
+
const modalContent = gameModal.querySelector('.transform');
|
| 475 |
+
modalContent.classList.remove('scale-100');
|
| 476 |
+
modalContent.classList.add('scale-0');
|
| 477 |
+
|
| 478 |
+
setTimeout(() => {
|
| 479 |
+
gameModal.classList.add('hidden');
|
| 480 |
+
initGame();
|
| 481 |
+
startGame();
|
| 482 |
+
}, 300);
|
| 483 |
+
});
|
| 484 |
+
|
| 485 |
+
closeModalButton.addEventListener('click', () => {
|
| 486 |
+
const modalContent = gameModal.querySelector('.transform');
|
| 487 |
+
modalContent.classList.remove('scale-100');
|
| 488 |
+
modalContent.classList.add('scale-0');
|
| 489 |
+
|
| 490 |
+
setTimeout(() => {
|
| 491 |
+
gameModal.classList.add('hidden');
|
| 492 |
+
initGame();
|
| 493 |
+
}, 300);
|
| 494 |
+
});
|
| 495 |
+
|
| 496 |
+
// Initialize the game
|
| 497 |
+
initGame();
|
| 498 |
+
});
|
| 499 |
+
</script>
|
| 500 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=A3qualityo/game" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 501 |
+
</html>
|
prompts.txt
ADDED
|
File without changes
|