Update index.html
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Space Shooter</title><style>body {margin: 0;overflow: hidden;background: black;display: flex;justify-content: center;align-items: center;height: 100vh;font-family: Arial;color: white;}#gameCanvas {border: 2px solid white;background-image:radial-gradient(white 1px, transparent 0),radial-gradient(white 1px, transparent 0);background-size: 50px 50px;background-position: 0 0, 25px 25px;display: none;}#menu {text-align: center;}.difficulty-btn {padding: 10px 20px;margin: 10px;font-size: 18px;cursor: pointer;background: #333;color: white;border: 2px solid white;border-radius: 5px;}.difficulty-btn:hover {background: #555;}#score {position: absolute;top: 20px;left: 20px;font-size: 24px;}#gameOver {position: absolute;font-size: 48px;text-align: center;display: none;}</style></head><body><div id="menu"><h1>Space Shooter</h1><h2>Select Difficulty:</h2><button class="difficulty-btn" onclick="startGame('easy')">Easy</button><button class="difficulty-btn" onclick="startGame('medium')">Medium</button><button class="difficulty-btn" onclick="startGame('hard')">Hard</button></div><div id="score">Score: <span id="scoreValue">0</span></div><canvas id="gameCanvas" width="800" height="600"></canvas><div id="gameOver">Game Over!<br>Press R to Restart</div><script>const canvas = document.getElementById('gameCanvas');const ctx = canvas.getContext('2d');const scoreEl = document.getElementById('scoreValue');const gameOverEl = document.getElementById('gameOver');const menuEl = document.getElementById('menu');let audioCtx;let player = {x: canvas.width/2,y: 500,speed: 5,size: 30};let bullets = [];let enemies = [];let score = 0;let gameOver = false;let keys = {left: false,right: false};let gameConfig = {easy: {enemySpeed: 2,spawnRate: 0.01,playerSpeed: 5},medium: {enemySpeed: 3,spawnRate: 0.02,playerSpeed: 6},hard: {enemySpeed: 4,spawnRate: 0.03,playerSpeed: 7}};let currentConfig;function startGame(difficulty) {menuEl.style.display = 'none';canvas.style.display = 'block';currentConfig = gameConfig[difficulty];player.speed = currentConfig.playerSpeed;resetGame();if (!audioCtx) {audio = setupAudio();}}function setupAudio() {audioCtx = new (window.AudioContext || window.webkitAudioContext)();function playNote(freq, startTime, duration) {const osc = audioCtx.createOscillator();const gain = audioCtx.createGain();osc.connect(gain);gain.connect(audioCtx.destination);osc.type = 'square';osc.frequency.setValueAtTime(freq, startTime);gain.gain.setValueAtTime(0.1, startTime);gain.gain.exponentialRampToValueAtTime(0.01, startTime + duration);osc.start(startTime);osc.stop(startTime + duration);}function playBGM() {const notes = [440, 523, 659, 784];setInterval(() => {if (!gameOver) {playNote(notes[Math.floor(Math.random() * notes.length)],audioCtx.currentTime,0.1);}}, 200);}function playShoot() {playNote(880, audioCtx.currentTime, 0.1);}playBGM();return { playShoot };}function drawPlayer() {ctx.fillStyle = 'yellow';ctx.beginPath();for (let i = 0; i < 5; i++) {const angle = (i * 4 * Math.PI) / 5 - Math.PI / 2;const x = player.x + player.size * Math.cos(angle);const y = player.y + player.size * Math.sin(angle);i === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);}ctx.closePath();ctx.fill();}function createEnemy() {if (Math.random() < currentConfig.spawnRate) {enemies.push({x: Math.random() * (canvas.width - 30) + 15,y: -30,speed: currentConfig.enemySpeed});}}function updatePlayer() {if (keys.left) {player.x = Math.max(player.size, player.x - player.speed);}if (keys.right) {player.x = Math.min(canvas.width - player.size, player.x + player.speed);}}function updateGame() {updatePlayer();bullets = bullets.filter(bullet => {bullet.y -= 8;return bullet.y > 0;});enemies = enemies.filter(enemy => {enemy.y += enemy.speed;if (Math.abs(enemy.x - player.x) < 30 &&Math.abs(enemy.y - player.y) < 30) {gameOver = true;gameOverEl.style.display = 'block';}return enemy.y < canvas.height;});bullets.forEach((bullet, bi) => {enemies.forEach((enemy, ei) => {if (Math.abs(bullet.x - enemy.x) < 30 &&Math.abs(bullet.y - enemy.y) < 30) {bullets.splice(bi, 1);enemies.splice(ei, 1);score += 100;scoreEl.textContent = score;}});});createEnemy();}function draw() {ctx.clearRect(0, 0, canvas.width, canvas.height);drawPlayer();ctx.fillStyle = 'white';bullets.forEach(bullet => {ctx.fillRect(bullet.x - 2, bullet.y - 8, 4, 16);});ctx.font = '30px Arial';enemies.forEach(enemy => {ctx.fillText('🐱', enemy.x - 15, enemy.y + 10);});}function gameLoop() {if (!gameOver) {updateGame();draw();requestAnimationFrame(gameLoop);}}function resetGame() {player.x = canvas.width/2;bullets = [];enemies = [];score = 0;gameOver = false;scoreEl.textContent = '0';gameOverEl.style.display = 'none';gameLoop();}function returnToMenu() {canvas.style.display = 'none';menuEl.style.display = 'block';gameOverEl.style.display = 'none';}let audio;document.addEventListener('keydown', (e) => {if (gameOver) {if (e.key.toLowerCase() === 'r') {returnToMenu();}return;}switch(e.key) {case 'ArrowLeft':keys.left = true;break;case 'ArrowRight':keys.right = true;break;case ' ':bullets.push({x: player.x,y: player.y - 20});if (audio) audio.playShoot();break;}});document.addEventListener('keyup', (e) => {switch(e.key) {case 'ArrowLeft':keys.left = false;break;case 'ArrowRight':keys.right = false;break;}});</script></body></html><script async data-explicit-opt-in="true" data-cookie-opt-in="true" src="https://vercel.live/_next-live/feedback/feedback.js"></script>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274<!DOCTYPE html><html><head><title>Rotating Arrows System</title><style>body {margin: 0;display: flex;justify-content: center;align-items: center;min-height: 100vh;background: #1a1a1a;font-family: Arial, sans-serif;color: white;}#container {position: relative;text-align: center;}.screen {display: none;margin-bottom: 20px;}.active {display: block;}.arrow-config {background: rgba(255, 255, 255, 0.1);padding: 15px;margin: 10px;border-radius: 8px;}button {padding: 10px 20px;margin: 5px;font-size: 16px;background: #4a90e2;border: none;border-radius: 5px;color: white;cursor: pointer;transition: all 0.3s ease;}button:hover {background: #357abd;transform: translateY(-2px);}input {width: 60px;padding: 5px;margin: 5px;border: none;border-radius: 3px;background: rgba(255, 255, 255, 0.2);color: white;}input:focus {outline: none;background: rgba(255, 255, 255, 0.3);}canvas {background: #333;border-radius: 8px;margin-top: 20px;}#resetBtn {position: fixed;top: 20px;right: 20px;background: #e74c3c;}#resetBtn:hover {background: #c0392b;}.controls {margin-top: 20px;}h2 {color: #4a90e2;margin-bottom: 20px;}.arrow-config label {display: inline-block;width: 60px;text-align: right;margin-right: 10px;}</style></head><body><button id="resetBtn" onclick="reset()" style="display: none;">Reset</button><div id="container"><div id="startScreen" class="screen active"><h2>Select Number of Arrows</h2><div><button onclick="selectArrows(2)">2 Arrows</button><button onclick="selectArrows(3)">3 Arrows</button><button onclick="selectArrows(4)">4 Arrows</button><button onclick="selectArrows(5)">5 Arrows</button></div></div><div id="configScreen" class="screen"><h2>Configure Arrows</h2><div id="arrowConfigs"></div><button onclick="startAnimation()">Start Animation</button></div><canvas id="canvas" width="800" height="600" style="display: none;"></canvas></div><script>let arrows = [];let animationId = null;let canvas, ctx;let pathPoints = [];class Arrow {constructor(length, speed) {this.length = length * 50;this.speed = speed;this.angle = 0;}}function selectArrows(num) {document.getElementById('startScreen').classList.remove('active');document.getElementById('configScreen').classList.add('active');document.getElementById('resetBtn').style.display = 'block';const configsDiv = document.getElementById('arrowConfigs');configsDiv.innerHTML = '';for(let i = 0; i < num; i++) {const speed = (Math.random() * 4 + 1).toFixed(1);const length = (Math.random() * 4 + 1).toFixed(1);const config = document.createElement('div');config.className = 'arrow-config';config.innerHTML = `<h3>Arrow ${i + 1}</h3><div><label>Speed:</label><input type="number" min="0.1" max="5" step="0.1" value="${speed}" id="speed${i}"></div><div><label>Length:</label><input type="number" min="0.1" max="5" step="0.1" value="${length}" id="length${i}"></div>`;configsDiv.appendChild(config);}}function startAnimation() {arrows = [];const inputs = document.querySelectorAll('.arrow-config input');for(let i = 0; i < inputs.length/2; i++) {const speed = parseFloat(document.getElementById(`speed${i}`).value);const length = parseFloat(document.getElementById(`length${i}`).value);arrows.push(new Arrow(length, speed));}document.getElementById('configScreen').classList.remove('active');canvas = document.getElementById('canvas');canvas.style.display = 'block';ctx = canvas.getContext('2d');pathPoints = [];if(animationId) cancelAnimationFrame(animationId);animate();}function animate() {// Clear canvasctx.fillStyle = '#333';ctx.fillRect(0, 0, canvas.width, canvas.height);// Start from centerlet x = canvas.width / 2;let y = canvas.height / 2;let totalAngle = 0;// Draw arrowsfor(let i = 0; i < arrows.length; i++) {const arrow = arrows[i];arrow.angle += arrow.speed * 0.02;totalAngle += arrow.angle;// Draw arrow linectx.beginPath();ctx.moveTo(x, y);const endX = x + Math.cos(totalAngle) * arrow.length;const endY = y + Math.sin(totalAngle) * arrow.length;ctx.lineTo(endX, endY);ctx.strokeStyle = '#4a90e2';ctx.lineWidth = 3;ctx.stroke();// Draw jointctx.beginPath();ctx.arc(x, y, 5, 0, Math.PI * 2);ctx.fillStyle = '#2ecc71';ctx.fill();// Update start point for next arrowx = endX;y = endY;// Store path point for last arrowif(i === arrows.length - 1) {pathPoints.push({x, y});if(pathPoints.length > 200) pathPoints.shift();}}// Draw pathif(pathPoints.length > 1) {ctx.beginPath();ctx.moveTo(pathPoints[0].x, pathPoints[0].y);for(let i = 1; i < pathPoints.length; i++) {const point = pathPoints[i];ctx.lineTo(point.x, point.y);}ctx.strokeStyle = '#e74c3c';ctx.lineWidth = 2;ctx.stroke();}animationId = requestAnimationFrame(animate);}function reset() {if(animationId) {cancelAnimationFrame(animationId);animationId = null;}arrows = [];pathPoints = [];document.getElementById('startScreen').classList.add('active');document.getElementById('configScreen').classList.remove('active');document.getElementById('canvas').style.display = 'none';document.getElementById('resetBtn').style.display = 'none';const configsDiv = document.getElementById('arrowConfigs');configsDiv.innerHTML = '';}// Initializewindow.onload = () => {canvas = document.getElementById('canvas');ctx = canvas.getContext('2d');};</script></body></html><script async data-explicit-opt-in="true" data-cookie-opt-in="true" src="https://vercel.live/_next-live/feedback/feedback.js"></script>
index.html+219-260