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