Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +437 -19
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: spacespacespace
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: pink
|
| 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,437 @@
|
|
| 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>Cyber Flappy</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
|
| 9 |
+
<style>
|
| 10 |
+
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
|
| 11 |
+
|
| 12 |
+
body {
|
| 13 |
+
font-family: 'Orbitron', sans-serif;
|
| 14 |
+
overflow: hidden;
|
| 15 |
+
background-color: #0a0a1a;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
#game-container {
|
| 19 |
+
position: relative;
|
| 20 |
+
width: 400px;
|
| 21 |
+
height: 600px;
|
| 22 |
+
margin: 0 auto;
|
| 23 |
+
overflow: hidden;
|
| 24 |
+
border: 3px solid #00f0ff;
|
| 25 |
+
box-shadow: 0 0 20px #00f0ff, inset 0 0 20px #00f0ff;
|
| 26 |
+
border-radius: 10px;
|
| 27 |
+
background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 100%);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
#bird {
|
| 31 |
+
position: absolute;
|
| 32 |
+
width: 40px;
|
| 33 |
+
height: 30px;
|
| 34 |
+
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%2300f0ff" d="M23,11.5L19.95,10l2.52-1.5c0.19-0.11,0.25-0.35,0.14-0.53l-0.81-1.41c-0.11-0.19-0.35-0.25-0.53-0.14L18.5,8.05 17,5.05C16.89,4.86,16.65,4.8,16.47,4.91l-1.41,0.81C14.86,5.83,14.8,6.07,14.91,6.25L16.5,9l-3.5-1.45V5.5 c0-0.28-0.22-0.5-0.5-0.5h-2C10.22,5,10,5.22,10,5.5v2.05L6.5,9L8.09,6.25C8.2,6.07,8.14,5.83,7.95,5.72L6.54,4.91 C6.35,4.8,6.11,4.86,6,5.05L4.5,8.05L2.24,6.92C2.06,6.81,1.82,6.87,1.71,7.06L0.9,8.47C0.79,8.65,0.85,8.89,1.04,9L3.05,10L0,11.5 c-0.19,0.11-0.25,0.35-0.14,0.53l0.81,1.41c0.11,0.19,0.35,0.25,0.53,0.14L4.5,12.95L6,15.95c0.11,0.19,0.35,0.25,0.53,0.14 l1.41-0.81c0.19-0.11,0.25-0.35,0.14-0.53L6.5,12l3.5,1.45v2.05c0,0.28,0.22,0.5,0.5,0.5h2c0.28,0,0.5-0.22,0.5-0.5v-2.05 L17,12l-1.59,2.75c-0.11,0.19-0.07,0.42,0.12,0.53l1.41,0.81c0.19,0.11,0.42,0.07,0.53-0.12L19.5,12.95l2.26,1.13 c0.19,0.09,0.42,0.03,0.53-0.16l0.81-1.41C23.25,11.85,23.19,11.61,23,11.5z"/></svg>');
|
| 35 |
+
background-size: contain;
|
| 36 |
+
background-repeat: no-repeat;
|
| 37 |
+
filter: drop-shadow(0 0 5px #00f0ff);
|
| 38 |
+
z-index: 10;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.pipe {
|
| 42 |
+
position: absolute;
|
| 43 |
+
width: 60px;
|
| 44 |
+
background-color: #00f0ff;
|
| 45 |
+
box-shadow: 0 0 10px #00f0ff;
|
| 46 |
+
border: 2px solid #00f0ff;
|
| 47 |
+
border-radius: 5px;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.pipe-top {
|
| 51 |
+
top: 0;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.pipe-bottom {
|
| 55 |
+
bottom: 0;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.score {
|
| 59 |
+
position: absolute;
|
| 60 |
+
top: 20px;
|
| 61 |
+
width: 100%;
|
| 62 |
+
text-align: center;
|
| 63 |
+
font-size: 24px;
|
| 64 |
+
color: #00f0ff;
|
| 65 |
+
text-shadow: 0 0 5px #00f0ff;
|
| 66 |
+
z-index: 20;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.game-over {
|
| 70 |
+
position: absolute;
|
| 71 |
+
top: 0;
|
| 72 |
+
left: 0;
|
| 73 |
+
width: 100%;
|
| 74 |
+
height: 100%;
|
| 75 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 76 |
+
display: flex;
|
| 77 |
+
flex-direction: column;
|
| 78 |
+
justify-content: center;
|
| 79 |
+
align-items: center;
|
| 80 |
+
z-index: 30;
|
| 81 |
+
color: #00f0ff;
|
| 82 |
+
text-shadow: 0 0 5px #00f0ff;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.start-screen {
|
| 86 |
+
position: absolute;
|
| 87 |
+
top: 0;
|
| 88 |
+
left: 0;
|
| 89 |
+
width: 100%;
|
| 90 |
+
height: 100%;
|
| 91 |
+
display: flex;
|
| 92 |
+
flex-direction: column;
|
| 93 |
+
justify-content: center;
|
| 94 |
+
align-items: center;
|
| 95 |
+
z-index: 30;
|
| 96 |
+
color: #00f0ff;
|
| 97 |
+
text-shadow: 0 0 5px #00f0ff;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.grid-pattern {
|
| 101 |
+
position: absolute;
|
| 102 |
+
top: 0;
|
| 103 |
+
left: 0;
|
| 104 |
+
width: 100%;
|
| 105 |
+
height: 100%;
|
| 106 |
+
background-image:
|
| 107 |
+
linear-gradient(rgba(0, 240, 255, 0.05) 1px, transparent 1px),
|
| 108 |
+
linear-gradient(90deg, rgba(0, 240, 255, 0.05) 1px, transparent 1px);
|
| 109 |
+
background-size: 20px 20px;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.neon-btn {
|
| 113 |
+
background: transparent;
|
| 114 |
+
color: #00f0ff;
|
| 115 |
+
border: 2px solid #00f0ff;
|
| 116 |
+
padding: 10px 20px;
|
| 117 |
+
margin-top: 20px;
|
| 118 |
+
font-family: 'Orbitron', sans-serif;
|
| 119 |
+
font-size: 16px;
|
| 120 |
+
cursor: pointer;
|
| 121 |
+
box-shadow: 0 0 10px #00f0ff, inset 0 0 10px #00f0ff;
|
| 122 |
+
transition: all 0.3s;
|
| 123 |
+
border-radius: 5px;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
.neon-btn:hover {
|
| 127 |
+
background: rgba(0, 240, 255, 0.2);
|
| 128 |
+
box-shadow: 0 0 20px #00f0ff, inset 0 0 20px #00f0ff;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.stars {
|
| 132 |
+
position: absolute;
|
| 133 |
+
top: 0;
|
| 134 |
+
left: 0;
|
| 135 |
+
width: 100%;
|
| 136 |
+
height: 100%;
|
| 137 |
+
z-index: 1;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.star {
|
| 141 |
+
position: absolute;
|
| 142 |
+
background-color: #00f0ff;
|
| 143 |
+
border-radius: 50%;
|
| 144 |
+
box-shadow: 0 0 5px #00f0ff;
|
| 145 |
+
}
|
| 146 |
+
</style>
|
| 147 |
+
</head>
|
| 148 |
+
<body class="flex items-center justify-center min-h-screen bg-gray-900">
|
| 149 |
+
<div class="text-center">
|
| 150 |
+
<h1 class="text-4xl font-bold mb-4 text-cyan-400 neon-text">CYBER FLAPPY</h1>
|
| 151 |
+
<div id="game-container">
|
| 152 |
+
<div class="stars" id="stars"></div>
|
| 153 |
+
<div class="grid-pattern"></div>
|
| 154 |
+
<div id="bird"></div>
|
| 155 |
+
<div class="score" id="score">0</div>
|
| 156 |
+
<div class="start-screen" id="start-screen">
|
| 157 |
+
<h2 class="text-3xl mb-4">CYBER FLAPPY</h2>
|
| 158 |
+
<p class="mb-6">Press SPACE or CLICK to fly</p>
|
| 159 |
+
<button class="neon-btn" id="start-btn">START GAME</button>
|
| 160 |
+
</div>
|
| 161 |
+
<div class="game-over hidden" id="game-over">
|
| 162 |
+
<h2 class="text-3xl mb-4">GAME OVER</h2>
|
| 163 |
+
<p class="text-xl mb-2">Score: <span id="final-score">0</span></p>
|
| 164 |
+
<p class="text-xl mb-6">High Score: <span id="high-score">0</span></p>
|
| 165 |
+
<button class="neon-btn" id="restart-btn">PLAY AGAIN</button>
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
<div class="mt-4 text-cyan-400">
|
| 169 |
+
<p>Controls: SPACE or CLICK to fly</p>
|
| 170 |
+
</div>
|
| 171 |
+
</div>
|
| 172 |
+
|
| 173 |
+
<script>
|
| 174 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 175 |
+
// Game elements
|
| 176 |
+
const gameContainer = document.getElementById('game-container');
|
| 177 |
+
const bird = document.getElementById('bird');
|
| 178 |
+
const scoreElement = document.getElementById('score');
|
| 179 |
+
const finalScoreElement = document.getElementById('final-score');
|
| 180 |
+
const highScoreElement = document.getElementById('high-score');
|
| 181 |
+
const startScreen = document.getElementById('start-screen');
|
| 182 |
+
const gameOverScreen = document.getElementById('game-over');
|
| 183 |
+
const startBtn = document.getElementById('start-btn');
|
| 184 |
+
const restartBtn = document.getElementById('restart-btn');
|
| 185 |
+
const starsContainer = document.getElementById('stars');
|
| 186 |
+
|
| 187 |
+
// Game variables
|
| 188 |
+
let gameRunning = false;
|
| 189 |
+
let score = 0;
|
| 190 |
+
let highScore = localStorage.getItem('cyberFlappyHighScore') || 0;
|
| 191 |
+
let birdY = 300;
|
| 192 |
+
let birdVelocity = 0;
|
| 193 |
+
let gravity = 0.5;
|
| 194 |
+
let jumpForce = -10;
|
| 195 |
+
let pipes = [];
|
| 196 |
+
let pipeGap = 180;
|
| 197 |
+
let pipeWidth = 60;
|
| 198 |
+
let pipeFrequency = 1500; // ms
|
| 199 |
+
let lastPipeTime = 0;
|
| 200 |
+
let gameSpeed = 3;
|
| 201 |
+
let animationId;
|
| 202 |
+
let lastTime = 0;
|
| 203 |
+
|
| 204 |
+
// Create stars background
|
| 205 |
+
function createStars() {
|
| 206 |
+
starsContainer.innerHTML = '';
|
| 207 |
+
const starCount = 100;
|
| 208 |
+
|
| 209 |
+
for (let i = 0; i < starCount; i++) {
|
| 210 |
+
const star = document.createElement('div');
|
| 211 |
+
star.className = 'star';
|
| 212 |
+
|
| 213 |
+
const size = Math.random() * 3;
|
| 214 |
+
star.style.width = `${size}px`;
|
| 215 |
+
star.style.height = `${size}px`;
|
| 216 |
+
|
| 217 |
+
star.style.left = `${Math.random() * 100}%`;
|
| 218 |
+
star.style.top = `${Math.random() * 100}%`;
|
| 219 |
+
|
| 220 |
+
// Twinkle animation
|
| 221 |
+
const delay = Math.random() * 5;
|
| 222 |
+
star.style.animation = `twinkle ${2 + Math.random() * 3}s infinite ${delay}s`;
|
| 223 |
+
|
| 224 |
+
starsContainer.appendChild(star);
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
// Initialize game
|
| 229 |
+
function initGame() {
|
| 230 |
+
birdY = 300;
|
| 231 |
+
birdVelocity = 0;
|
| 232 |
+
score = 0;
|
| 233 |
+
scoreElement.textContent = score;
|
| 234 |
+
pipes = [];
|
| 235 |
+
|
| 236 |
+
// Clear existing pipes
|
| 237 |
+
document.querySelectorAll('.pipe').forEach(pipe => pipe.remove());
|
| 238 |
+
|
| 239 |
+
// Position bird
|
| 240 |
+
bird.style.top = `${birdY}px`;
|
| 241 |
+
bird.style.left = '100px';
|
| 242 |
+
|
| 243 |
+
highScoreElement.textContent = highScore;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
// Start game
|
| 247 |
+
function startGame() {
|
| 248 |
+
gameRunning = true;
|
| 249 |
+
startScreen.classList.add('hidden');
|
| 250 |
+
gameOverScreen.classList.add('hidden');
|
| 251 |
+
initGame();
|
| 252 |
+
lastTime = performance.now();
|
| 253 |
+
gameLoop(lastTime);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
// Game over
|
| 257 |
+
function gameOver() {
|
| 258 |
+
gameRunning = false;
|
| 259 |
+
cancelAnimationFrame(animationId);
|
| 260 |
+
|
| 261 |
+
// Update high score
|
| 262 |
+
if (score > highScore) {
|
| 263 |
+
highScore = score;
|
| 264 |
+
localStorage.setItem('cyberFlappyHighScore', highScore);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
finalScoreElement.textContent = score;
|
| 268 |
+
highScoreElement.textContent = highScore;
|
| 269 |
+
gameOverScreen.classList.remove('hidden');
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
// Jump
|
| 273 |
+
function jump() {
|
| 274 |
+
if (!gameRunning) return;
|
| 275 |
+
birdVelocity = jumpForce;
|
| 276 |
+
|
| 277 |
+
// Add jump effect
|
| 278 |
+
bird.style.transform = 'rotate(-30deg)';
|
| 279 |
+
setTimeout(() => {
|
| 280 |
+
bird.style.transform = 'rotate(0deg)';
|
| 281 |
+
}, 200);
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
// Create pipe
|
| 285 |
+
function createPipe(timestamp) {
|
| 286 |
+
if (timestamp - lastPipeTime > pipeFrequency) {
|
| 287 |
+
lastPipeTime = timestamp;
|
| 288 |
+
|
| 289 |
+
const pipeHeight = Math.floor(Math.random() * (gameContainer.offsetHeight - pipeGap - 100)) + 50;
|
| 290 |
+
|
| 291 |
+
// Top pipe
|
| 292 |
+
const topPipe = document.createElement('div');
|
| 293 |
+
topPipe.className = 'pipe pipe-top';
|
| 294 |
+
topPipe.style.height = `${pipeHeight}px`;
|
| 295 |
+
topPipe.style.left = `${gameContainer.offsetWidth}px`;
|
| 296 |
+
gameContainer.appendChild(topPipe);
|
| 297 |
+
|
| 298 |
+
// Bottom pipe
|
| 299 |
+
const bottomPipe = document.createElement('div');
|
| 300 |
+
bottomPipe.className = 'pipe pipe-bottom';
|
| 301 |
+
bottomPipe.style.height = `${gameContainer.offsetHeight - pipeHeight - pipeGap}px`;
|
| 302 |
+
bottomPipe.style.left = `${gameContainer.offsetWidth}px`;
|
| 303 |
+
gameContainer.appendChild(bottomPipe);
|
| 304 |
+
|
| 305 |
+
pipes.push({
|
| 306 |
+
top: topPipe,
|
| 307 |
+
bottom: bottomPipe,
|
| 308 |
+
x: gameContainer.offsetWidth,
|
| 309 |
+
passed: false
|
| 310 |
+
});
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
// Update pipes
|
| 315 |
+
function updatePipes(timestamp) {
|
| 316 |
+
createPipe(timestamp);
|
| 317 |
+
|
| 318 |
+
pipes.forEach((pipe, index) => {
|
| 319 |
+
pipe.x -= gameSpeed;
|
| 320 |
+
pipe.top.style.left = `${pipe.x}px`;
|
| 321 |
+
pipe.bottom.style.left = `${pipe.x}px`;
|
| 322 |
+
|
| 323 |
+
// Check if pipe is passed
|
| 324 |
+
if (!pipe.passed && pipe.x < 100 - pipeWidth) {
|
| 325 |
+
pipe.passed = true;
|
| 326 |
+
score++;
|
| 327 |
+
scoreElement.textContent = score;
|
| 328 |
+
|
| 329 |
+
// Increase difficulty
|
| 330 |
+
if (score % 5 === 0) {
|
| 331 |
+
gameSpeed += 0.5;
|
| 332 |
+
pipeFrequency = Math.max(800, pipeFrequency - 50);
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
// Remove pipes that are off screen
|
| 337 |
+
if (pipe.x < -pipeWidth) {
|
| 338 |
+
pipe.top.remove();
|
| 339 |
+
pipe.bottom.remove();
|
| 340 |
+
pipes.splice(index, 1);
|
| 341 |
+
}
|
| 342 |
+
});
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
// Check collisions
|
| 346 |
+
function checkCollisions() {
|
| 347 |
+
// Check if bird hits the ground or ceiling
|
| 348 |
+
if (birdY >= gameContainer.offsetHeight - 30 || birdY <= 0) {
|
| 349 |
+
gameOver();
|
| 350 |
+
return;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
// Check if bird hits a pipe
|
| 354 |
+
const birdRect = {
|
| 355 |
+
x: 100,
|
| 356 |
+
y: birdY,
|
| 357 |
+
width: 40,
|
| 358 |
+
height: 30
|
| 359 |
+
};
|
| 360 |
+
|
| 361 |
+
for (const pipe of pipes) {
|
| 362 |
+
const topPipeRect = {
|
| 363 |
+
x: pipe.x,
|
| 364 |
+
y: 0,
|
| 365 |
+
width: pipeWidth,
|
| 366 |
+
height: parseInt(pipe.top.style.height)
|
| 367 |
+
};
|
| 368 |
+
|
| 369 |
+
const bottomPipeRect = {
|
| 370 |
+
x: pipe.x,
|
| 371 |
+
y: gameContainer.offsetHeight - parseInt(pipe.bottom.style.height),
|
| 372 |
+
width: pipeWidth,
|
| 373 |
+
height: parseInt(pipe.bottom.style.height)
|
| 374 |
+
};
|
| 375 |
+
|
| 376 |
+
if (
|
| 377 |
+
birdRect.x < pipe.x + pipeWidth &&
|
| 378 |
+
birdRect.x + birdRect.width > pipe.x &&
|
| 379 |
+
(birdRect.y < topPipeRect.height || birdRect.y + birdRect.height > bottomPipeRect.y)
|
| 380 |
+
) {
|
| 381 |
+
gameOver();
|
| 382 |
+
return;
|
| 383 |
+
}
|
| 384 |
+
}
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
// Game loop
|
| 388 |
+
function gameLoop(timestamp) {
|
| 389 |
+
if (!gameRunning) return;
|
| 390 |
+
|
| 391 |
+
const deltaTime = timestamp - lastTime;
|
| 392 |
+
lastTime = timestamp;
|
| 393 |
+
|
| 394 |
+
// Update bird
|
| 395 |
+
birdVelocity += gravity;
|
| 396 |
+
birdY += birdVelocity;
|
| 397 |
+
bird.style.top = `${birdY}px`;
|
| 398 |
+
|
| 399 |
+
// Update pipes
|
| 400 |
+
updatePipes(timestamp);
|
| 401 |
+
|
| 402 |
+
// Check collisions
|
| 403 |
+
checkCollisions();
|
| 404 |
+
|
| 405 |
+
animationId = requestAnimationFrame(gameLoop);
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
// Event listeners
|
| 409 |
+
document.addEventListener('keydown', (e) => {
|
| 410 |
+
if (e.code === 'Space') {
|
| 411 |
+
e.preventDefault();
|
| 412 |
+
jump();
|
| 413 |
+
}
|
| 414 |
+
});
|
| 415 |
+
|
| 416 |
+
gameContainer.addEventListener('click', () => {
|
| 417 |
+
jump();
|
| 418 |
+
});
|
| 419 |
+
|
| 420 |
+
startBtn.addEventListener('click', startGame);
|
| 421 |
+
restartBtn.addEventListener('click', startGame);
|
| 422 |
+
|
| 423 |
+
// Initialize
|
| 424 |
+
createStars();
|
| 425 |
+
initGame();
|
| 426 |
+
|
| 427 |
+
// Add animation for the start screen
|
| 428 |
+
const neonTexts = document.querySelectorAll('.neon-text');
|
| 429 |
+
setInterval(() => {
|
| 430 |
+
neonTexts.forEach(text => {
|
| 431 |
+
text.style.textShadow = `0 0 ${5 + Math.random() * 5}px #00f0ff`;
|
| 432 |
+
});
|
| 433 |
+
}, 1000);
|
| 434 |
+
});
|
| 435 |
+
</script>
|
| 436 |
+
<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=zazial/spacespacespace" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 437 |
+
</html>
|