Spaces:
Running
Running
Download index.html from has200/memory-match: direct link, hf CLI and curl.
- Browser
- Download file 13.3 kB
-
https://huggingface.co/spaces/has200/memory-match/resolve/main/index.html
- Command line
-
hf download hf://spaces/has200/memory-match/index.html
-
curl -L -o index.html https://huggingface.co/spaces/has200/memory-match/resolve/main/index.html
13.3 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Memory Match Game</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .card { | |
| perspective: 1000px; | |
| transform-style: preserve-3d; | |
| transition: all 0.5s ease; | |
| } | |
| .card-inner { | |
| position: relative; | |
| width: 100%; | |
| height: 100%; | |
| transform-style: preserve-3d; | |
| transition: transform 0.6s; | |
| } | |
| .card.flipped .card-inner { | |
| 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: 0.5rem; | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); | |
| } | |
| .card-front { | |
| background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); | |
| transform: rotateY(180deg); | |
| } | |
| .card-back { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| color: white; | |
| } | |
| .matched { | |
| opacity: 0.6; | |
| transform: scale(0.95); | |
| } | |
| @keyframes celebration { | |
| 0% { transform: scale(1); } | |
| 50% { transform: scale(1.2); } | |
| 100% { transform: scale(1); } | |
| } | |
| .celebration { | |
| animation: celebration 0.5s ease; | |
| } | |
| .confetti { | |
| position: absolute; | |
| width: 10px; | |
| height: 10px; | |
| background-color: #f00; | |
| opacity: 0; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4"> | |
| <div class="w-full max-w-4xl mx-auto"> | |
| <div class="flex justify-between items-center mb-8"> | |
| <h1 class="text-3xl font-bold text-indigo-800">Memory Match</h1> | |
| <div class="flex space-x-6"> | |
| <div class="bg-white p-3 rounded-lg shadow-md flex items-center"> | |
| <i class="fas fa-stopwatch text-indigo-600 mr-2"></i> | |
| <span id="timer" class="font-semibold">00:00</span> | |
| </div> | |
| <div class="bg-white p-3 rounded-lg shadow-md flex items-center"> | |
| <i class="fas fa-star text-yellow-500 mr-2"></i> | |
| <span id="score" class="font-semibold">0</span> | |
| </div> | |
| <div class="bg-white p-3 rounded-lg shadow-md flex items-center"> | |
| <i class="fas fa-redo-alt text-indigo-600 mr-2"></i> | |
| <button id="restart" class="font-semibold">Restart</button> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-4 gap-4" id="game-board"> | |
| <!-- Cards will be generated here by JavaScript --> | |
| </div> | |
| <div id="win-message" class="hidden mt-8 p-6 bg-gradient-to-r from-green-400 to-blue-500 rounded-lg text-white text-center"> | |
| <h2 class="text-2xl font-bold mb-2">Congratulations! 🎉</h2> | |
| <p class="mb-4">You matched all pairs in <span id="final-time">00:00</span> with <span id="final-moves">0</span> moves!</p> | |
| <button id="play-again" class="px-6 py-2 bg-white text-indigo-600 rounded-full font-semibold hover:bg-gray-100 transition">Play Again</button> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const gameBoard = document.getElementById('game-board'); | |
| const timerElement = document.getElementById('timer'); | |
| const scoreElement = document.getElementById('score'); | |
| const restartButton = document.getElementById('restart'); | |
| const winMessage = document.getElementById('win-message'); | |
| const finalTimeElement = document.getElementById('final-time'); | |
| const finalMovesElement = document.getElementById('final-moves'); | |
| const playAgainButton = document.getElementById('play-again'); | |
| const icons = [ | |
| 'fa-heart', 'fa-star', 'fa-moon', 'fa-sun', | |
| 'fa-cloud', 'fa-bolt', 'fa-bell', 'fa-key', | |
| 'fa-flag', 'fa-gem', 'fa-ghost', 'fa-hashtag' | |
| ]; | |
| let cards = []; | |
| let hasFlippedCard = false; | |
| let lockBoard = false; | |
| let firstCard, secondCard; | |
| let matchedPairs = 0; | |
| let moves = 0; | |
| let timerInterval; | |
| let seconds = 0; | |
| // Initialize game | |
| initGame(); | |
| function initGame() { | |
| // Reset game state | |
| matchedPairs = 0; | |
| moves = 0; | |
| seconds = 0; | |
| clearInterval(timerInterval); | |
| updateScore(); | |
| updateTimer(); | |
| winMessage.classList.add('hidden'); | |
| // Create pairs of cards | |
| const gameIcons = [...icons.slice(0, 6), ...icons.slice(0, 6)]; | |
| shuffleArray(gameIcons); | |
| // Clear the game board | |
| gameBoard.innerHTML = ''; | |
| cards = []; | |
| // Create card elements | |
| gameIcons.forEach((icon, index) => { | |
| const card = document.createElement('div'); | |
| card.className = 'card h-32 cursor-pointer'; | |
| card.dataset.index = index; | |
| card.innerHTML = ` | |
| <div class="card-inner h-full"> | |
| <div class="card-front"> | |
| <i class="fas ${icon} text-4xl text-indigo-600"></i> | |
| </div> | |
| <div class="card-back"> | |
| <i class="fas fa-question text-4xl"></i> | |
| </div> | |
| </div> | |
| `; | |
| card.addEventListener('click', flipCard); | |
| gameBoard.appendChild(card); | |
| cards.push(card); | |
| }); | |
| // Start timer | |
| timerInterval = setInterval(() => { | |
| seconds++; | |
| updateTimer(); | |
| }, 1000); | |
| } | |
| function flipCard() { | |
| if (lockBoard) return; | |
| if (this === firstCard) return; | |
| if (this.classList.contains('matched')) return; | |
| this.classList.add('flipped'); | |
| if (!hasFlippedCard) { | |
| // First click | |
| hasFlippedCard = true; | |
| firstCard = this; | |
| return; | |
| } | |
| // Second click | |
| secondCard = this; | |
| moves++; | |
| updateScore(); | |
| checkForMatch(); | |
| } | |
| function checkForMatch() { | |
| const firstIcon = firstCard.querySelector('.card-front i').className; | |
| const secondIcon = secondCard.querySelector('.card-front i').className; | |
| const isMatch = firstIcon === secondIcon; | |
| if (isMatch) { | |
| disableCards(); | |
| matchedPairs++; | |
| if (matchedPairs === 6) { | |
| clearInterval(timerInterval); | |
| setTimeout(() => { | |
| showWinMessage(); | |
| createConfetti(); | |
| }, 500); | |
| } | |
| } else { | |
| unflipCards(); | |
| } | |
| } | |
| function disableCards() { | |
| firstCard.classList.add('matched'); | |
| secondCard.classList.add('matched'); | |
| firstCard.classList.add('celebration'); | |
| secondCard.classList.add('celebration'); | |
| setTimeout(() => { | |
| firstCard.classList.remove('celebration'); | |
| secondCard.classList.remove('celebration'); | |
| }, 500); | |
| resetBoard(); | |
| } | |
| function unflipCards() { | |
| lockBoard = true; | |
| setTimeout(() => { | |
| firstCard.classList.remove('flipped'); | |
| secondCard.classList.remove('flipped'); | |
| resetBoard(); | |
| }, 1000); | |
| } | |
| function resetBoard() { | |
| [hasFlippedCard, lockBoard] = [false, false]; | |
| [firstCard, secondCard] = [null, null]; | |
| } | |
| function updateScore() { | |
| scoreElement.textContent = moves; | |
| } | |
| function updateTimer() { | |
| const minutes = Math.floor(seconds / 60).toString().padStart(2, '0'); | |
| const secs = (seconds % 60).toString().padStart(2, '0'); | |
| timerElement.textContent = `${minutes}:${secs}`; | |
| } | |
| function showWinMessage() { | |
| finalTimeElement.textContent = timerElement.textContent; | |
| finalMovesElement.textContent = moves; | |
| winMessage.classList.remove('hidden'); | |
| } | |
| function createConfetti() { | |
| for (let i = 0; i < 100; i++) { | |
| const confetti = document.createElement('div'); | |
| confetti.className = 'confetti'; | |
| // Random position | |
| const xPos = Math.random() * window.innerWidth; | |
| const yPos = Math.random() * -100; | |
| // Random color | |
| const colors = ['#f00', '#0f0', '#00f', '#ff0', '#f0f', '#0ff']; | |
| const randomColor = colors[Math.floor(Math.random() * colors.length)]; | |
| // Random size | |
| const size = Math.random() * 10 + 5; | |
| // Random animation duration | |
| const duration = Math.random() * 3 + 2; | |
| confetti.style.left = `${xPos}px`; | |
| confetti.style.top = `${yPos}px`; | |
| confetti.style.backgroundColor = randomColor; | |
| confetti.style.width = `${size}px`; | |
| confetti.style.height = `${size}px`; | |
| confetti.style.borderRadius = '50%'; | |
| // Animation | |
| confetti.style.transition = `all ${duration}s linear`; | |
| confetti.style.opacity = '1'; | |
| document.body.appendChild(confetti); | |
| setTimeout(() => { | |
| confetti.style.top = `${window.innerHeight}px`; | |
| confetti.style.opacity = '0'; | |
| }, 10); | |
| // Remove after animation | |
| setTimeout(() => { | |
| confetti.remove(); | |
| }, duration * 1000); | |
| } | |
| } | |
| // Helper function to shuffle array | |
| function shuffleArray(array) { | |
| for (let i = array.length - 1; i > 0; i--) { | |
| const j = Math.floor(Math.random() * (i + 1)); | |
| [array[i], array[j]] = [array[j], array[i]]; | |
| } | |
| return array; | |
| } | |
| // Event listeners | |
| restartButton.addEventListener('click', initGame); | |
| playAgainButton.addEventListener('click', initGame); | |
| }); | |
| </script> | |
| <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=has200/memory-match" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |