File size: 19,069 Bytes
9f1410d 5d403fb |
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 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SkyFlap Odyssey: Aerial Avian Adventure</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.60.0/phaser.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
color: #f8fafc;
overflow-x: hidden;
}
.game-container {
position: relative;
max-width: 1200px;
margin: 0 auto;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
#gameCanvas {
display: block;
margin: 0 auto;
border: 3px solid #475569;
border-radius: 15px;
background: linear-gradient(180deg, #1e40af 0%, #3b82f6 100%);
}
.stats-overlay {
position: absolute;
top: 20px;
left: 20px;
z-index: 10;
background: rgba(15, 23, 42, 0.8);
padding: 15px;
border-radius: 12px;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.score-animation {
animation: scorePop 0.6s ease-out;
}
@keyframes scorePop {
0% { transform: scale(1); }
50% { transform: scale(1.3); }
100% { transform: scale(1); }
}
.power-up-indicator {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.6; }
100% { opacity: 1; }
}
.menu-transition {
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.parallax-bg {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -1;
}
.bg-layer-1 { animation: scrollBg 60s linear infinite; }
.bg-layer-2 { animation: scrollBg 40s linear infinite; }
.bg-layer-3 { animation: scrollBg 20s linear infinite; }
@keyframes scrollBg {
from { transform: translateX(0); }
to { transform: translateX(-100%); }
}
</style>
</head>
<body class="min-h-screen flex items-center justify-center p-4">
<!-- Parallax Background Elements -->
<div class="parallax-bg">
<div class="bg-layer-1 absolute inset-0 opacity-20">
<div class="flex">
<div class="w-64 h-64 bg-gradient-to-br from-blue-400 to-purple-500 rounded-full blur-3xl"></div>
<div class="w-48 h-48 bg-gradient-to-br from-green-400 to-blue-500 rounded-full blur-2xl ml-32"></div>
</div>
</div>
<div class="bg-layer-2 absolute inset-0 opacity-15">
<div class="flex mt-32">
<div class="w-32 h-32 bg-gradient-to-br from-yellow-400 to-red-500 rounded-full blur-2xl"></div>
<div class="w-56 h-56 bg-gradient-to-br from-pink-400 to-red-500 rounded-full blur-3xl ml-64"></div>
</div>
</div>
<div class="bg-layer-3 absolute inset-0 opacity-10">
<div class="flex mt-64">
<div class="w-40 h-40 bg-gradient-to-br from-purple-400 to-pink-500 rounded-full blur-2xl ml-96"></div>
</div>
</div>
</div>
<div class="game-container">
<!-- Game Stats Overlay -->
<div class="stats-overlay">
<div class="flex items-center space-x-6">
<div class="text-center">
<div class="text-sm text-gray-400">SCORE</div>
<div id="currentScore" class="text-2xl font-bold text-white score-animation">0</div>
</div>
<div class="text-center">
<div class="text-sm text-gray-400">BEST</div>
<div id="bestScore" class="text-xl font-semibold text-yellow-400">0</div>
</div>
<div id="powerUpDisplay" class="hidden">
<div class="text-center">
<div class="text-sm text-gray-400">POWER</div>
<div class="text-lg font-semibold text-green-400 power-up-indicator">ACTIVE</div>
</div>
</div>
</div>
</div>
<!-- Game Canvas -->
<div id="gameCanvas" class="w-full h-auto"></div>
<!-- Start Menu -->
<div id="startMenu" class="absolute inset-0 flex flex-col items-center justify-center bg-gradient-to-br from-black/80 to-blue-900/80 backdrop-blur-sm">
<div class="text-center space-y-6">
<h1 class="text-5xl font-bold bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-transparent">
SkyFlap Odyssey
</h1>
<p class="text-xl text-gray-300">Aerial Avian Adventure</p>
<div class="space-y-4 mt-8">
<button onclick="startGame()" class="w-64 bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-300 transform hover:scale-105">
<i data-feather="play" class="inline mr-2"></i>
Start Flight
</button>
<button onclick="showSettings()" class="w-64 bg-gray-700 hover:bg-gray-600 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-300">
<i data-feather="settings" class="inline mr-2"></i>
Game Settings
</button>
</div>
<div class="mt-6 text-sm text-gray-400">
<p>Tap, Click, or Press SPACE to flap</p>
<p>Gamepad supported</p>
</div>
</div>
</div>
<!-- Game Over Menu -->
<div id="gameOverMenu" class="absolute inset-0 flex flex-col items-center justify-center bg-gradient-to-br from-red-900/80 to-black/80 backdrop-blur-sm hidden">
<div class="text-center space-y-6">
<h2 class="text-4xl font-bold text-red-400">Flight Terminated</h2>
<div class="bg-black/50 p-6 rounded-2xl space-y-4">
<div class="text-2xl font-semibold">Final Score: <span id="finalScore" class="text-yellow-400">0</span></div>
<div class="text-lg">Best Score: <span id="finalBestScore" class="text-green-400">0</span></div>
<div class="space-y-3">
<button onclick="restartGame()" class="w-64 bg-gradient-to-r from-green-500 to-blue-600 hover:from-green-600 hover:to-blue-700 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-300">
<i data-feather="refresh-cw" class="inline mr-2"></i>
Fly Again
</button>
<button onclick="showStartMenu()" class="w-64 bg-gray-700 hover:bg-gray-600 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-300">
<i data-feather="home" class="inline mr-2"></i>
Main Menu
</button>
</div>
</div>
</div>
<!-- Settings Menu -->
<div id="settingsMenu" class="absolute inset-0 flex flex-col items-center justify-center bg-gradient-to-br from-gray-900/80 to-black/80 backdrop-blur-sm hidden">
<div class="bg-black/70 p-8 rounded-2xl max-w-md w-full space-y-6">
<h2 class="text-3xl font-bold text-center text-white">Settings</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">Music Volume</label>
<input type="range" min="0" max="100" value="50" class="w-full h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer slider">
</div>
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">SFX Volume</label>
<input type="range" min="0" max="100" value="70" class="w-full h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer slider">
</div>
<div class="flex items-center justify-between">
<span class="text-sm font-medium text-gray-300">Visual Effects</span>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" checked class="sr-only peer">
<div class="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-500"></div>
</label>
</div>
</div>
<div class="flex space-x-4 pt-4">
<button onclick="saveSettings()" class="flex-1 bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white font-semibold py-2 px-4 rounded-xl transition-all duration-300">
Save
</button>
<button onclick="showStartMenu()" class="flex-1 bg-gray-700 hover:bg-gray-600 text-white font-semibold py-2 px-4 rounded-xl transition-all duration-300">
Cancel
</button>
</div>
</div>
</div>
</div>
<!-- Control Instructions -->
<div class="mt-8 text-center space-y-2">
<div class="flex justify-center space-x-8 text-sm text-gray-400">
<div class="flex items-center space-x-2">
<i data-feather="mouse-pointer"></i>
<span>Click/Tap</span>
</div>
<div class="flex items-center space-x-2">
<i data-feather="square"></i>
<span>Space Bar</span>
</div>
<div class="flex items-center space-x-2">
<i data-feather="gamepad"></i>
<span>Gamepad A</span>
</div>
</div>
</div>
<script>
// Initialize game variables
let game;
let currentScore = 0;
let bestScore = 0;
let isGameRunning = false;
// Load best score from localStorage
if (localStorage.getItem('skyflapBestScore')) {
bestScore = parseInt(localStorage.getItem('skyflapBestScore'));
document.getElementById('bestScore').textContent = bestScore;
}
// Game configuration
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'gameCanvas',
physics: {
default: 'arcade',
arcade: {
gravity: { y: 800 },
debug: false
}
},
scene: {
preload: preload,
create: create,
update: update
},
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH
}
};
function preload() {
// Load placeholder assets - in real implementation, these would be actual game assets
this.load.image('bird', 'http://static.photos/nature/64x64/1');
this.load.image('pipe', 'http://static.photos/green/128x512/2');
this.load.image('background', 'http://static.photos/blue/800x600/3');
}
function create() {
// Create background
this.add.image(400, 300, 'background');
// Create bird
this.bird = this.physics.add.sprite(100, 300, 'bird');
this.bird.setCollideWorldBounds(true);
// Create pipe group
this.pipes = this.physics.add.group();
// Input handlers
this.input.on('pointerdown', flap, this);
this.input.keyboard.on('keydown-SPACE', flap, this);
// Timer for pipe generation
this.pipeTimer = this.time.addEvent({
delay: 1500,
callback: generatePipe,
callbackScope: this,
loop: true
});
// Collision detection
this.physics.add.collider(this.bird, this.pipes, gameOver, null, this);
// Score text
this.scoreText = this.add.text(400, 50, '0', {
fontSize: '32px',
fill: '#ffffff',
stroke: '#000000',
strokeThickness: 4
}).setOrigin(0.5);
}
function update() {
if (!isGameRunning) return;
// Rotate bird based on velocity
this.bird.rotation = Phaser.Math.Clamp(this.bird.body.velocity.y * 0.01, -0.5, 0.5);
}
function flap() {
if (!isGameRunning) return;
this.bird.setVelocityY(-300);
}
function generatePipe() {
if (!isGameRunning) return;
const gap = 200;
const pipeX = 800;
const pipeY = Phaser.Math.Between(100, 500);
// Top pipe
const topPipe = this.pipes.create(pipeX, pipeY - gap / 2, 'pipe');
topPipe.setScale(1, -1);
topPipe.setVelocityX(-200);
// Bottom pipe
const bottomPipe = this.pipes.create(pipeX, pipeY + gap / 2, 'pipe');
bottomPipe.setVelocityX(-200);
// Remove pipes when they go off screen
this.time.delayedCall(4000, () => {
topPipe.destroy();
bottomPipe.destroy();
});
// Increment score when passing pipes
this.time.delayedCall(2000, () => {
currentScore++;
updateScore();
});
}
function gameOver() {
isGameRunning = false;
// Update best score
if (currentScore > bestScore) {
bestScore = currentScore;
localStorage.setItem('skyflapBestScore', bestScore);
// Show game over menu
document.getElementById('finalScore').textContent = currentScore;
document.getElementById('finalBestScore').textContent = bestScore;
document.getElementById('gameOverMenu').classList.remove('hidden');
}
function updateScore() {
document.getElementById('currentScore').textContent = currentScore;
document.getElementById('bestScore').textContent = bestScore;
// Add animation
document.getElementById('currentScore').classList.add('score-animation');
setTimeout(() => {
document.getElementById('currentScore').classList.remove('score-animation');
}, 600);
}
// UI Control Functions
function startGame() {
document.getElementById('startMenu').classList.add('hidden');
document.getElementById('gameOverMenu').classList.add('hidden');
isGameRunning = true;
currentScore = 0;
updateScore();
// Initialize game if not already created
if (!game) {
game = new Phaser.Game(config);
} else {
// Reset game state
game.scene.restart();
}
}
function restartGame() {
document.getElementById('gameOverMenu').classList.add('hidden');
isGameRunning = true;
currentScore = 0;
updateScore();
game.scene.restart();
}
function showStartMenu() {
document.getElementById('startMenu').classList.remove('hidden');
document.getElementById('settingsMenu').classList.add('hidden');
document.getElementById('gameOverMenu').classList.add('hidden');
isGameRunning = false;
}
function showSettings() {
document.getElementById('startMenu').classList.add('hidden');
document.getElementById('settingsMenu').classList.remove('hidden');
}
function saveSettings() {
// Save settings logic would go here
showStartMenu();
}
// Gamepad support
window.addEventListener("gamepadconnected", (e) => {
console.log("Gamepad connected:", e.gamepad.id);
});
window.addEventListener("gamepaddisconnected", (e) => {
console.log("Gamepad disconnected:", e.gamepad.id);
});
// Initialize Feather Icons
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
});
// Responsive adjustments
function handleResize() {
const container = document.querySelector('.game-container');
const canvas = document.getElementById('gameCanvas');
if (window.innerWidth < 768) {
container.style.maxWidth = '100%';
if (game) {
game.scale.setGameSize(400, 300);
}
} else {
container.style.maxWidth = '1200px';
if (game) {
game.scale.setGameSize(800, 600);
}
}
}
window.addEventListener('resize', handleResize);
handleResize();
</script>
</body>
</html>
|