Download index.html from Hossar/savior: direct link, hf CLI and curl.
- Browser
- Download file 18.5 kB
-
https://huggingface.co/spaces/Hossar/savior/resolve/main/index.html
- Command line
-
hf download hf://spaces/Hossar/savior/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Hossar/savior/resolve/main/index.html
18.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Fruit Catcher Game</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <style> | |
| @keyframes float { | |
| 0% { transform: translateY(0px); } | |
| 50% { transform: translateY(-10px); } | |
| 100% { transform: translateY(0px); } | |
| } | |
| .floating { | |
| animation: float 3s ease-in-out infinite; | |
| } | |
| .game-object { | |
| position: absolute; | |
| transition: transform 0.1s; | |
| user-select: none; | |
| } | |
| .explosion { | |
| position: absolute; | |
| background: radial-gradient(circle, rgba(255,200,0,0.8) 0%, rgba(255,100,0,0.6) 50%, rgba(255,0,0,0) 70%); | |
| border-radius: 50%; | |
| transform: scale(0); | |
| opacity: 1; | |
| animation: explode 0.5s forwards; | |
| } | |
| @keyframes explode { | |
| to { | |
| transform: scale(3); | |
| opacity: 0; | |
| } | |
| } | |
| .shake { | |
| animation: shake 0.5s; | |
| } | |
| @keyframes shake { | |
| 0%, 100% { transform: translateX(0); } | |
| 10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); } | |
| 20%, 40%, 60%, 80% { transform: translateX(5px); } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gradient-to-b from-blue-400 to-blue-600 min-h-screen overflow-hidden font-sans"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <!-- Game Title --> | |
| <h1 class="text-5xl font-bold text-center text-white mb-2 floating">π Fruit Catcher π</h1> | |
| <p class="text-center text-white mb-8">Catch the fruits, avoid the bombs!</p> | |
| <!-- Game Info --> | |
| <div class="flex justify-between items-center mb-4 px-4"> | |
| <div class="bg-white bg-opacity-20 rounded-lg p-3"> | |
| <p class="text-white font-bold">Score: <span id="score" class="text-yellow-300">0</span></p> | |
| </div> | |
| <div class="bg-white bg-opacity-20 rounded-lg p-3"> | |
| <p class="text-white font-bold">Lives: <span id="lives" class="text-red-300">β€οΈβ€οΈβ€οΈ</span></p> | |
| </div> | |
| <div class="bg-white bg-opacity-20 rounded-lg p-3"> | |
| <p class="text-white font-bold">Level: <span id="level" class="text-green-300">1</span></p> | |
| </div> | |
| </div> | |
| <!-- Game Area --> | |
| <div id="game-area" class="relative bg-blue-300 bg-opacity-30 rounded-xl border-4 border-blue-400 h-96 w-full overflow-hidden"> | |
| <!-- Player Basket --> | |
| <div id="basket" class="absolute bottom-4 left-1/2 transform -translate-x-1/2 w-24 h-16 bg-gradient-to-r from-amber-700 to-amber-900 rounded-lg flex justify-center items-center"> | |
| <div class="w-full h-4 bg-amber-800 rounded-b-lg absolute -bottom-4"></div> | |
| <div class="w-4 h-8 bg-amber-900 rounded-full absolute -bottom-8 left-4"></div> | |
| <div class="w-4 h-8 bg-amber-900 rounded-full absolute -bottom-8 right-4"></div> | |
| </div> | |
| <!-- Start Screen --> | |
| <div id="start-screen" class="absolute inset-0 flex flex-col justify-center items-center bg-black bg-opacity-70 text-white"> | |
| <h2 class="text-4xl font-bold mb-6">Fruit Catcher</h2> | |
| <p class="text-xl mb-8 text-center px-4">Use your mouse or arrow keys to move the basket.<br>Catch fruits for points, avoid bombs!</p> | |
| <button id="start-btn" class="bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-8 rounded-full text-xl transition-all transform hover:scale-105"> | |
| Start Game | |
| </button> | |
| <div class="mt-8 flex space-x-4"> | |
| <div class="text-center"> | |
| <div class="text-4xl">π</div> | |
| <div class="text-sm">+10 pts</div> | |
| </div> | |
| <div class="text-center"> | |
| <div class="text-4xl">π</div> | |
| <div class="text-sm">+15 pts</div> | |
| </div> | |
| <div class="text-center"> | |
| <div class="text-4xl">π</div> | |
| <div class="text-sm">+20 pts</div> | |
| </div> | |
| <div class="text-center"> | |
| <div class="text-4xl">π£</div> | |
| <div class="text-sm">-1 life</div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Game Over Screen --> | |
| <div id="game-over" class="absolute inset-0 flex flex-col justify-center items-center bg-black bg-opacity-70 text-white hidden"> | |
| <h2 class="text-4xl font-bold mb-4">Game Over!</h2> | |
| <p class="text-2xl mb-2">Your score: <span id="final-score" class="text-yellow-300">0</span></p> | |
| <p class="text-xl mb-6">Level reached: <span id="final-level" class="text-green-300">1</span></p> | |
| <button id="restart-btn" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-3 px-8 rounded-full text-xl transition-all transform hover:scale-105"> | |
| Play Again | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Controls --> | |
| <div class="mt-6 text-center text-white"> | |
| <p>Controls: Mouse or Arrow Keys (β β)</p> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Game elements | |
| const gameArea = document.getElementById('game-area'); | |
| const basket = document.getElementById('basket'); | |
| const scoreDisplay = document.getElementById('score'); | |
| const livesDisplay = document.getElementById('lives'); | |
| const levelDisplay = document.getElementById('level'); | |
| const startScreen = document.getElementById('start-screen'); | |
| const gameOverScreen = document.getElementById('game-over'); | |
| const startBtn = document.getElementById('start-btn'); | |
| const restartBtn = document.getElementById('restart-btn'); | |
| const finalScoreDisplay = document.getElementById('final-score'); | |
| const finalLevelDisplay = document.getElementById('final-level'); | |
| // Game state | |
| let score = 0; | |
| let lives = 3; | |
| let level = 1; | |
| let gameRunning = false; | |
| let basketPosition = gameArea.offsetWidth / 2 - basket.offsetWidth / 2; | |
| let basketWidth = basket.offsetWidth; | |
| let gameAreaWidth = gameArea.offsetWidth; | |
| let gameAreaHeight = gameArea.offsetHeight; | |
| let fallingObjects = []; | |
| let objectInterval; | |
| let speedInterval; | |
| let objectSpeed = 3; | |
| let spawnRate = 1500; // ms | |
| // Fruits and their values | |
| const fruits = [ | |
| { emoji: 'π', value: 10, color: 'bg-red-500' }, | |
| { emoji: 'π', value: 15, color: 'bg-yellow-400' }, | |
| { emoji: 'π', value: 20, color: 'bg-red-600' }, | |
| { emoji: 'π', value: 12, color: 'bg-orange-500' }, | |
| { emoji: 'π', value: 18, color: 'bg-pink-500' } | |
| ]; | |
| // Bombs | |
| const bombs = [ | |
| { emoji: 'π£', penalty: 1, color: 'bg-gray-700' } | |
| ]; | |
| // Initialize game | |
| function initGame() { | |
| score = 0; | |
| lives = 3; | |
| level = 1; | |
| objectSpeed = 3; | |
| spawnRate = 1500; | |
| scoreDisplay.textContent = score; | |
| livesDisplay.textContent = 'β€οΈβ€οΈβ€οΈ'; | |
| levelDisplay.textContent = level; | |
| basketPosition = gameAreaWidth / 2 - basketWidth / 2; | |
| basket.style.left = `${basketPosition}px`; | |
| // Clear any existing objects | |
| fallingObjects.forEach(obj => { | |
| if (obj.element && obj.element.parentNode) { | |
| obj.element.remove(); | |
| } | |
| }); | |
| fallingObjects = []; | |
| // Clear intervals | |
| clearInterval(objectInterval); | |
| clearInterval(speedInterval); | |
| } | |
| // Start game | |
| function startGame() { | |
| initGame(); | |
| gameRunning = true; | |
| startScreen.classList.add('hidden'); | |
| gameOverScreen.classList.add('hidden'); | |
| // Start spawning objects | |
| objectInterval = setInterval(createFallingObject, spawnRate); | |
| // Gradually increase difficulty | |
| speedInterval = setInterval(() => { | |
| level++; | |
| levelDisplay.textContent = level; | |
| objectSpeed += 0.5; | |
| spawnRate = Math.max(500, spawnRate - 100); | |
| // Clear and reset interval with new spawn rate | |
| clearInterval(objectInterval); | |
| objectInterval = setInterval(createFallingObject, spawnRate); | |
| }, 15000); // Every 15 seconds | |
| } | |
| // Game over | |
| function endGame() { | |
| gameRunning = false; | |
| clearInterval(objectInterval); | |
| clearInterval(speedInterval); | |
| finalScoreDisplay.textContent = score; | |
| finalLevelDisplay.textContent = level; | |
| gameOverScreen.classList.remove('hidden'); | |
| } | |
| // Create falling objects (fruits or bombs) | |
| function createFallingObject() { | |
| if (!gameRunning) return; | |
| // 20% chance of bomb, 80% chance of fruit | |
| const isBomb = Math.random() < 0.2; | |
| const objectType = isBomb | |
| ? bombs[Math.floor(Math.random() * bombs.length)] | |
| : fruits[Math.floor(Math.random() * fruits.length)]; | |
| const object = document.createElement('div'); | |
| object.className = `game-object text-3xl flex items-center justify-center rounded-full w-12 h-12 ${objectType.color}`; | |
| object.textContent = objectType.emoji; | |
| // Random horizontal position | |
| const xPos = Math.random() * (gameAreaWidth - 50); | |
| object.style.left = `${xPos}px`; | |
| object.style.top = '-50px'; | |
| gameArea.appendChild(object); | |
| const newObject = { | |
| element: object, | |
| x: xPos, | |
| y: -50, | |
| width: 50, | |
| height: 50, | |
| value: objectType.value || 0, | |
| penalty: objectType.penalty || 0, | |
| speed: objectSpeed + (Math.random() * 2 - 1) // Slight speed variation | |
| }; | |
| fallingObjects.push(newObject); | |
| } | |
| // Update game state | |
| function updateGame() { | |
| if (!gameRunning) return; | |
| // Update falling objects | |
| fallingObjects.forEach((obj, index) => { | |
| obj.y += obj.speed; | |
| obj.element.style.top = `${obj.y}px`; | |
| // Check if object is caught by basket | |
| if ( | |
| obj.y + obj.height >= gameAreaHeight - 80 && | |
| obj.y <= gameAreaHeight - 40 && | |
| obj.x + obj.width >= basketPosition && | |
| obj.x <= basketPosition + basketWidth | |
| ) { | |
| // Object caught | |
| if (obj.penalty) { | |
| // It's a bomb! | |
| lives -= obj.penalty; | |
| livesDisplay.textContent = 'β€οΈ'.repeat(Math.max(0, lives)) + 'β‘'.repeat(Math.max(0, 3 - lives)); | |
| // Create explosion effect | |
| const explosion = document.createElement('div'); | |
| explosion.className = 'explosion'; | |
| explosion.style.left = `${obj.x + obj.width/2 - 15}px`; | |
| explosion.style.top = `${obj.y + obj.height/2 - 15}px`; | |
| explosion.style.width = '30px'; | |
| explosion.style.height = '30px'; | |
| gameArea.appendChild(explosion); | |
| // Remove explosion after animation | |
| setTimeout(() => { | |
| explosion.remove(); | |
| }, 500); | |
| // Shake basket | |
| basket.classList.add('shake'); | |
| setTimeout(() => { | |
| basket.classList.remove('shake'); | |
| }, 500); | |
| // Game over if no lives left | |
| if (lives <= 0) { | |
| endGame(); | |
| } | |
| } else { | |
| // It's a fruit - add to score | |
| score += obj.value; | |
| scoreDisplay.textContent = score; | |
| // Create floating score effect | |
| const scoreEffect = document.createElement('div'); | |
| scoreEffect.className = 'absolute text-yellow-300 font-bold text-xl'; | |
| scoreEffect.textContent = `+${obj.value}`; | |
| scoreEffect.style.left = `${obj.x + obj.width/2 - 15}px`; | |
| scoreEffect.style.top = `${obj.y - 20}px`; | |
| gameArea.appendChild(scoreEffect); | |
| // Animate and remove score effect | |
| setTimeout(() => { | |
| scoreEffect.style.transition = 'all 0.5s'; | |
| scoreEffect.style.opacity = '0'; | |
| scoreEffect.style.transform = 'translateY(-30px)'; | |
| setTimeout(() => { | |
| scoreEffect.remove(); | |
| }, 500); | |
| }, 0); | |
| } | |
| // Remove object | |
| obj.element.remove(); | |
| fallingObjects.splice(index, 1); | |
| } | |
| // Remove object if it falls past the bottom | |
| if (obj.y > gameAreaHeight) { | |
| obj.element.remove(); | |
| fallingObjects.splice(index, 1); | |
| } | |
| }); | |
| // Request next animation frame | |
| requestAnimationFrame(updateGame); | |
| } | |
| // Handle keyboard controls | |
| function handleKeyDown(e) { | |
| if (!gameRunning) return; | |
| const moveAmount = 20; | |
| if (e.key === 'ArrowLeft' || e.key === 'a') { | |
| basketPosition = Math.max(0, basketPosition - moveAmount); | |
| } else if (e.key === 'ArrowRight' || e.key === 'd') { | |
| basketPosition = Math.min(gameAreaWidth - basketWidth, basketPosition + moveAmount); | |
| } | |
| basket.style.left = `${basketPosition}px`; | |
| } | |
| // Handle mouse/touch controls | |
| function handleMouseMove(e) { | |
| if (!gameRunning) return; | |
| const rect = gameArea.getBoundingClientRect(); | |
| const mouseX = e.clientX - rect.left; | |
| // Keep basket within game area | |
| basketPosition = Math.max( | |
| 0, | |
| Math.min( | |
| mouseX - basketWidth / 2, | |
| gameAreaWidth - basketWidth | |
| ) | |
| ); | |
| basket.style.left = `${basketPosition}px`; | |
| } | |
| // Event listeners | |
| startBtn.addEventListener('click', () => { | |
| startGame(); | |
| updateGame(); | |
| }); | |
| restartBtn.addEventListener('click', () => { | |
| startGame(); | |
| updateGame(); | |
| }); | |
| document.addEventListener('keydown', handleKeyDown); | |
| gameArea.addEventListener('mousemove', handleMouseMove); | |
| gameArea.addEventListener('touchmove', (e) => { | |
| e.preventDefault(); | |
| handleMouseMove(e.touches[0]); | |
| }); | |
| // Initial setup | |
| basket.style.left = `${basketPosition}px`; | |
| }); | |
| </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=Hossar/savior" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |