Spaces:
Running
Running
Download index.html from BudBit3/techno-flappybird: direct link, hf CLI and curl.
- Browser
- Download file 17.3 kB
-
https://huggingface.co/spaces/BudBit3/techno-flappybird/resolve/main/index.html
- Command line
-
hf download hf://spaces/BudBit3/techno-flappybird/index.html
-
curl -L -o index.html https://huggingface.co/spaces/BudBit3/techno-flappybird/resolve/main/index.html
17.3 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Tech Flappy</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> | |
| @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Press+Start+2P&display=swap'); | |
| body { | |
| font-family: 'Orbitron', sans-serif; | |
| background-color: #0f0f1a; | |
| overflow: hidden; | |
| color: #00fffc; | |
| } | |
| #game-container { | |
| position: relative; | |
| width: 100vw; | |
| height: 100vh; | |
| overflow: hidden; | |
| background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%); | |
| } | |
| #game-canvas { | |
| display: block; | |
| margin: 0 auto; | |
| background-color: #0a0a12; | |
| border: 2px solid #00fffc; | |
| box-shadow: 0 0 20px rgba(0, 255, 252, 0.3); | |
| } | |
| .neon-text { | |
| text-shadow: 0 0 5px #00fffc, 0 0 10px #00fffc, 0 0 15px #00fffc; | |
| } | |
| .neon-border { | |
| border: 2px solid #00fffc; | |
| box-shadow: 0 0 10px rgba(0, 255, 252, 0.5); | |
| } | |
| .pixel-font { | |
| font-family: 'Press Start 2P', cursive; | |
| } | |
| .glow { | |
| animation: glow 2s infinite alternate; | |
| } | |
| @keyframes glow { | |
| from { | |
| box-shadow: 0 0 5px #00fffc, 0 0 10px rgba(0, 255, 252, 0.5); | |
| } | |
| to { | |
| box-shadow: 0 0 15px #00fffc, 0 0 30px rgba(0, 255, 252, 0.8); | |
| } | |
| } | |
| .pipe { | |
| background: linear-gradient(90deg, #00fffc 0%, #008e8b 100%); | |
| } | |
| .bird { | |
| background: linear-gradient(45deg, #ff00fc 0%, #00fffc 100%); | |
| border-radius: 50%; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="game-container" class="flex flex-col items-center justify-center"> | |
| <h1 class="text-4xl md:text-6xl font-bold mb-4 neon-text glow">TECH FLAPPY</h1> | |
| <div class="relative"> | |
| <canvas id="game-canvas" width="320" height="480" class="neon-border"></canvas> | |
| <!-- Start Screen --> | |
| <div id="start-screen" class="absolute inset-0 flex flex-col items-center justify-center bg-black bg-opacity-70"> | |
| <div class="text-center p-8 neon-border rounded-lg bg-gray-900"> | |
| <h2 class="text-2xl md:text-3xl font-bold mb-6 neon-text">TECH FLAPPY</h2> | |
| <p class="mb-6 text-sm md:text-base">Navigate through the binary pipes</p> | |
| <button id="start-btn" class="px-6 py-3 bg-transparent neon-border rounded-lg text-lg font-bold hover:bg-blue-900 hover:text-white transition-all duration-300 glow"> | |
| <i class="fas fa-play mr-2"></i> START | |
| </button> | |
| <div class="mt-6 text-xs"> | |
| <p>Press SPACE or CLICK to flap</p> | |
| <p class="mt-2">High Score: <span id="high-score-display">0</span></p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Game Over Screen --> | |
| <div id="game-over-screen" class="absolute inset-0 hidden flex-col items-center justify-center bg-black bg-opacity-70"> | |
| <div class="text-center p-8 neon-border rounded-lg bg-gray-900"> | |
| <h2 class="text-2xl md:text-3xl font-bold mb-2 neon-text">GAME OVER</h2> | |
| <p class="mb-1">Your score: <span id="final-score" class="font-bold">0</span></p> | |
| <p class="mb-6">High score: <span id="new-high-score" class="font-bold">0</span></p> | |
| <button id="restart-btn" class="px-6 py-3 bg-transparent neon-border rounded-lg text-lg font-bold hover:bg-blue-900 hover:text-white transition-all duration-300 glow"> | |
| <i class="fas fa-redo mr-2"></i> PLAY AGAIN | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="mt-6 flex items-center space-x-8"> | |
| <div class="text-center"> | |
| <p class="text-sm">SCORE</p> | |
| <p id="score-display" class="text-2xl font-bold neon-text">0</p> | |
| </div> | |
| <div class="text-center"> | |
| <p class="text-sm">BEST</p> | |
| <p id="current-high-score" class="text-2xl font-bold neon-text">0</p> | |
| </div> | |
| </div> | |
| <div class="mt-8 text-xs text-gray-500"> | |
| <p>© 2023 TECH FLAPPY | <i class="fas fa-code"></i> with <i class="fas fa-heart text-red-500"></i> by Dev</p> | |
| </div> | |
| </div> | |
| <audio id="flap-sound" src="https://assets.mixkit.co/sfx/preview/mixkit-arcade-game-jump-coin-216.mp3"></audio> | |
| <audio id="score-sound" src="https://assets.mixkit.co/sfx/preview/mixkit-unlock-game-notification-253.mp3"></audio> | |
| <audio id="hit-sound" src="https://assets.mixkit.co/sfx/preview/mixkit-arcade-game-explosion-275.mp3"></audio> | |
| <script> | |
| // Game variables | |
| const canvas = document.getElementById('game-canvas'); | |
| const ctx = canvas.getContext('2d'); | |
| const startScreen = document.getElementById('start-screen'); | |
| const gameOverScreen = document.getElementById('game-over-screen'); | |
| const startBtn = document.getElementById('start-btn'); | |
| const restartBtn = document.getElementById('restart-btn'); | |
| const scoreDisplay = document.getElementById('score-display'); | |
| const finalScoreDisplay = document.getElementById('final-score'); | |
| const highScoreDisplay = document.getElementById('high-score-display'); | |
| const currentHighScoreDisplay = document.getElementById('current-high-score'); | |
| const newHighScoreDisplay = document.getElementById('new-high-score'); | |
| // Sound effects | |
| const flapSound = document.getElementById('flap-sound'); | |
| const scoreSound = document.getElementById('score-sound'); | |
| const hitSound = document.getElementById('hit-sound'); | |
| // Game state | |
| let gameRunning = false; | |
| let score = 0; | |
| let highScore = localStorage.getItem('techFlappyHighScore') || 0; | |
| highScoreDisplay.textContent = highScore; | |
| currentHighScoreDisplay.textContent = highScore; | |
| // Bird properties - MODIFIED FOR SMOOTHER PHYSICS | |
| const bird = { | |
| x: 50, | |
| y: canvas.height / 2, | |
| width: 30, | |
| height: 30, | |
| velocity: 0, | |
| gravity: 0.3, // Reduced gravity for slower falling | |
| jump: -6, // Reduced jump force for less dramatic jumps | |
| draw() { | |
| ctx.fillStyle = '#00fffc'; | |
| ctx.beginPath(); | |
| ctx.arc(this.x, this.y, this.width / 2, 0, Math.PI * 2); | |
| ctx.fill(); | |
| // Add tech details to bird | |
| ctx.fillStyle = '#ff00fc'; | |
| ctx.beginPath(); | |
| ctx.arc(this.x - 5, this.y - 5, 3, 0, Math.PI * 2); | |
| ctx.fill(); | |
| ctx.beginPath(); | |
| ctx.arc(this.x + 5, this.y - 5, 3, 0, Math.PI * 2); | |
| ctx.fill(); | |
| }, | |
| update() { | |
| this.velocity += this.gravity; | |
| this.y += this.velocity; | |
| // Check if bird hits the ground or ceiling | |
| if (this.y + this.height / 2 > canvas.height || this.y - this.height / 2 < 0) { | |
| gameOver(); | |
| } | |
| }, | |
| flap() { | |
| this.velocity = this.jump; | |
| flapSound.currentTime = 0; | |
| flapSound.play(); | |
| } | |
| }; | |
| // Pipes | |
| const pipes = []; | |
| const pipeWidth = 60; | |
| const pipeGap = 120; | |
| let pipeTimer = 0; | |
| let pipeInterval = 1500; // milliseconds | |
| function createPipe() { | |
| const minHeight = 50; | |
| const maxHeight = canvas.height - pipeGap - minHeight; | |
| const height = Math.floor(Math.random() * (maxHeight - minHeight + 1) + minHeight); | |
| pipes.push({ | |
| x: canvas.width, | |
| height: height, | |
| passed: false | |
| }); | |
| } | |
| function drawPipes() { | |
| ctx.fillStyle = '#00fffc'; | |
| pipes.forEach(pipe => { | |
| // Top pipe | |
| ctx.fillRect(pipe.x, 0, pipeWidth, pipe.height); | |
| // Bottom pipe | |
| ctx.fillRect(pipe.x, pipe.height + pipeGap, pipeWidth, canvas.height - pipe.height - pipeGap); | |
| // Add tech details to pipes | |
| ctx.fillStyle = '#008e8b'; | |
| for (let i = 0; i < pipe.height; i += 15) { | |
| ctx.fillRect(pipe.x + 10, i + 5, pipeWidth - 20, 5); | |
| } | |
| for (let i = pipe.height + pipeGap; i < canvas.height; i += 15) { | |
| ctx.fillRect(pipe.x + 10, i + 5, pipeWidth - 20, 5); | |
| } | |
| ctx.fillStyle = '#00fffc'; | |
| }); | |
| } | |
| function updatePipes() { | |
| if (gameRunning) { | |
| pipeTimer += 16; // assuming 60fps | |
| if (pipeTimer > pipeInterval) { | |
| createPipe(); | |
| pipeTimer = 0; | |
| // Increase difficulty | |
| if (score > 0 && score % 5 === 0) { | |
| pipeInterval = Math.max(800, pipeInterval - 50); | |
| pipeGap = Math.max(80, pipeGap - 5); | |
| } | |
| } | |
| pipes.forEach((pipe, index) => { | |
| pipe.x -= 2; | |
| // Check if bird passed the pipe | |
| if (!pipe.passed && pipe.x + pipeWidth < bird.x) { | |
| pipe.passed = true; | |
| score++; | |
| scoreDisplay.textContent = score; | |
| scoreSound.currentTime = 0; | |
| scoreSound.play(); | |
| } | |
| // Check collision | |
| if ( | |
| bird.x + bird.width / 2 > pipe.x && | |
| bird.x - bird.width / 2 < pipe.x + pipeWidth && | |
| (bird.y - bird.height / 2 < pipe.height || | |
| bird.y + bird.height / 2 > pipe.height + pipeGap) | |
| ) { | |
| gameOver(); | |
| } | |
| // Remove pipes that are off screen | |
| if (pipe.x + pipeWidth < 0) { | |
| pipes.splice(index, 1); | |
| } | |
| }); | |
| } | |
| } | |
| // Background elements | |
| const stars = []; | |
| for (let i = 0; i < 100; i++) { | |
| stars.push({ | |
| x: Math.random() * canvas.width, | |
| y: Math.random() * canvas.height, | |
| size: Math.random() * 2 + 1, | |
| speed: Math.random() * 0.5 + 0.5 | |
| }); | |
| } | |
| function drawBackground() { | |
| // Draw space background | |
| ctx.fillStyle = '#0a0a12'; | |
| ctx.fillRect(0, 0, canvas.width, canvas.height); | |
| // Draw stars | |
| ctx.fillStyle = '#ffffff'; | |
| stars.forEach(star => { | |
| ctx.beginPath(); | |
| ctx.arc(star.x, star.y, star.size, 0, Math.PI * 2); | |
| ctx.fill(); | |
| }); | |
| // Draw grid lines | |
| ctx.strokeStyle = 'rgba(0, 255, 252, 0.1)'; | |
| ctx.lineWidth = 1; | |
| // Vertical lines | |
| for (let x = 0; x < canvas.width; x += 40) { | |
| ctx.beginPath(); | |
| ctx.moveTo(x, 0); | |
| ctx.lineTo(x, canvas.height); | |
| ctx.stroke(); | |
| } | |
| // Horizontal lines | |
| for (let y = 0; y < canvas.height; y += 40) { | |
| ctx.beginPath(); | |
| ctx.moveTo(0, y); | |
| ctx.lineTo(canvas.width, y); | |
| ctx.stroke(); | |
| } | |
| } | |
| // Game loop | |
| function gameLoop() { | |
| // Clear canvas | |
| ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| // Draw background | |
| drawBackground(); | |
| // Update and draw pipes | |
| updatePipes(); | |
| drawPipes(); | |
| // Update and draw bird | |
| bird.update(); | |
| bird.draw(); | |
| // Update stars | |
| stars.forEach(star => { | |
| star.x -= star.speed; | |
| if (star.x < 0) { | |
| star.x = canvas.width; | |
| star.y = Math.random() * canvas.height; | |
| } | |
| }); | |
| // Continue game loop if running | |
| if (gameRunning) { | |
| requestAnimationFrame(gameLoop); | |
| } | |
| } | |
| // Game controls | |
| function startGame() { | |
| // Reset game state | |
| score = 0; | |
| scoreDisplay.textContent = score; | |
| pipes.length = 0; | |
| pipeTimer = 0; | |
| bird.y = canvas.height / 2; | |
| bird.velocity = 0; | |
| // Show game and hide start screen | |
| startScreen.style.display = 'none'; | |
| gameOverScreen.style.display = 'none'; | |
| // Start game | |
| gameRunning = true; | |
| gameLoop(); | |
| } | |
| function gameOver() { | |
| gameRunning = false; | |
| hitSound.currentTime = 0; | |
| hitSound.play(); | |
| // Update high score if needed | |
| if (score > highScore) { | |
| highScore = score; | |
| localStorage.setItem('techFlappyHighScore', highScore); | |
| currentHighScoreDisplay.textContent = highScore; | |
| } | |
| // Show game over screen | |
| finalScoreDisplay.textContent = score; | |
| newHighScoreDisplay.textContent = highScore; | |
| gameOverScreen.style.display = 'flex'; | |
| } | |
| // Event listeners | |
| startBtn.addEventListener('click', startGame); | |
| restartBtn.addEventListener('click', startGame); | |
| // Keyboard controls | |
| document.addEventListener('keydown', (e) => { | |
| if (e.code === 'Space') { | |
| if (!gameRunning && startScreen.style.display !== 'none') { | |
| startGame(); | |
| } else if (gameRunning) { | |
| bird.flap(); | |
| } else if (!gameRunning && gameOverScreen.style.display === 'flex') { | |
| startGame(); | |
| } | |
| } | |
| }); | |
| // Mouse/touch controls | |
| canvas.addEventListener('click', () => { | |
| if (gameRunning) { | |
| bird.flap(); | |
| } | |
| }); | |
| // Mobile touch support | |
| canvas.addEventListener('touchstart', (e) => { | |
| e.preventDefault(); | |
| if (gameRunning) { | |
| bird.flap(); | |
| } else if (!gameRunning && startScreen.style.display !== 'none') { | |
| startGame(); | |
| } else if (!gameRunning && gameOverScreen.style.display === 'flex') { | |
| startGame(); | |
| } | |
| }); | |
| // Responsive canvas sizing | |
| function resizeCanvas() { | |
| const container = document.getElementById('game-container'); | |
| const scale = Math.min( | |
| container.clientWidth / 320, | |
| container.clientHeight / 480 | |
| ); | |
| canvas.style.width = `${320 * scale}px`; | |
| canvas.style.height = `${480 * scale}px`; | |
| } | |
| window.addEventListener('resize', resizeCanvas); | |
| resizeCanvas(); | |
| </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=BudBit3/techno-flappybird" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |