diff --git a/footer.js b/footer.js index 7f1574a..ec68f22 100644 --- a/footer.js +++ b/footer.js @@ -38,7 +38,7 @@ class Footer extends HTMLElement { // Add event listener for button click this.querySelector('.secret-button').addEventListener('click', () => { - window.location.href = 'secret/explenation.html'; // Open the secret.html file + window.location.href = 'secret/secret.html'; // Open the secret.html file }); } } diff --git a/secret/explenation.html b/secret/explenation.html deleted file mode 100644 index e051da1..0000000 --- a/secret/explenation.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - Game Landing Page - - - -
-
- - -
- -
-

Welcome to the Asteroid Game!

-

In this game, you control a spaceship that shoots at asteroids to avoid destruction and collect items for power-ups.

-

Your goal is to survive as long as possible while scoring points!

- -
-
- - - - diff --git a/secret/game.js b/secret/game.js index cf84dc9..1adae6c 100644 --- a/secret/game.js +++ b/secret/game.js @@ -1,4 +1,3 @@ -"use strict"; // Canvas setup const canvas = document.getElementById('gameCanvas'); const ctx = canvas.getContext('2d'); @@ -46,36 +45,7 @@ let rainbowSphereCooldown = 0; // Sphere types const sphereTypes = ['blue', 'yellow', 'green', 'rainbow']; -/// Control for left button press and release -function btnMoveLeft(isPressed) { - if (isPressed) { - player.dx = -player.speed; // Start moving left - } else { - player.dx = 0; // Stop moving when button is released - } -} - -// Control for shoot button click (simulates spacebar press) -function btnShoot() { - if (canShoot && !isGameOver) { - shootBullet(); - canShoot = false; // Prevent shooting until the button is "released" - } -} - -// Control for right button press and release -function btnMoveRight(isPressed) { - if (isPressed) { - player.dx = player.speed; // Start moving right - } else { - player.dx = 0; // Stop moving when button is released - } -} - -document.getElementById('shootBtn').addEventListener('mouseup', () => { - canShoot = true; // Allow shooting again when button is released -}); - +// Controls window.addEventListener('keydown', (e) => { if (e.key === 'ArrowLeft' || e.key === 'a') player.dx = -player.speed; if (e.key === 'ArrowRight' || e.key === 'd') player.dx = player.speed; @@ -109,8 +79,6 @@ function shootBullet() { lastBulletTime = now; ammo--; // Decrease ammo - totalBulletsFired++; // Increment total bullets fired - if (rapidFireActive) { // If rapid fire is active, fire bullets continuously with a short delay for (let i = 0; i < 3; i++) { @@ -225,7 +193,6 @@ function updateItems() { } function applyItemEffect(type) { - let points = Math.floor(Math.random() * 5) + 1; // Random points between 1 and 5 if (type === 'blue') { rapidFireActive = true; setTimeout(() => rapidFireActive = false, 15000); // 15 seconds of rapid fire @@ -242,7 +209,6 @@ function applyItemEffect(type) { shotgunActive = false; }, 15000); // 15 seconds with all effects } - score += points; // Add points when an item is collected } // Collision detection @@ -257,9 +223,7 @@ function checkCollisions() { ) { bullets.splice(bIndex, 1); asteroids.splice(aIndex, 1); - score += Math.floor(Math.random() * 5) + 1; // Add points when an asteroid is destroyed - // Visual feedback for destroyed asteroid - createExplosion(asteroid.x, asteroid.y); + score++; } }); }); @@ -276,15 +240,6 @@ function checkCollisions() { }); } -// Explosion effect -function createExplosion(x, y) { - ctx.fillStyle = 'yellow'; - ctx.beginPath(); - ctx.arc(x, y, 20, 0, Math.PI * 2); - ctx.fill(); - setTimeout(() => ctx.clearRect(x - 20, y - 20, 40, 40), 200); // Clear explosion after 200ms -} - // Draw elements function drawPlayer() { ctx.fillStyle = player.color; @@ -365,12 +320,23 @@ function gameLoop() { drawGameOver(); if (!isGameOver) { - if (Math.random() < 0.01) createAsteroid(); // 1% chance every frame to spawn an asteroid - if (Math.random() < 0.005) createItem(); // 0.5% chance to spawn an item + if (Math.random() < 0.02) { + createAsteroid(); + } + + if (Math.random() < 0.02) { + createItem(); + } + } + + // Difficulty increase over time + if (score > 0 && score % 50 === 0) { + asteroidSpawnInterval -= difficultyIncreaseRate; // Increase spawn rate (faster asteroids) + asteroidSpeedMultiplier += difficultyIncreaseRate; // Increase speed multiplier } requestAnimationFrame(gameLoop); } -// Start game loop +// Start the game gameLoop(); diff --git a/secret/secret.html b/secret/secret.html index 4cce9e5..afa0e3b 100644 --- a/secret/secret.html +++ b/secret/secret.html @@ -8,14 +8,6 @@ - - -
- - - -
- diff --git a/secret/style.css b/secret/style.css index d904269..eedaeef 100644 --- a/secret/style.css +++ b/secret/style.css @@ -1,43 +1,10 @@ body { - margin: 0; - overflow: hidden; -} - -canvas { - display: block; - background: black; - width: 100%; - height: 100%; -} - -.controls { - display: none; - position: absolute; - bottom: 20px; - left: 50%; - transform: translateX(-50%); - display: flex; - justify-content: space-between; - width: 80%; -} - -.control-btn { - display: none; - padding: 10px; - font-size: 18px; - background-color: rgba(0, 0, 0, 0.6); - color: white; - border: 1px solid #fff; - border-radius: 5px; - cursor: pointer; - flex-grow: 1; - margin: 0 5px; -} - -@media (max-width: 600px) { - .control-btn { - display: block; - font-size: 16px; - padding: 12px; + margin: 0; + overflow: hidden; } -} + + canvas { + display: block; + background: black; + } + \ No newline at end of file diff --git a/secret/styles.css b/secret/styles.css deleted file mode 100644 index 062d406..0000000 --- a/secret/styles.css +++ /dev/null @@ -1,74 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box; - } - - body, html { - height: 100%; - font-family: Arial, sans-serif; - display: flex; - justify-content: center; - align-items: center; - background-color: #000; - color: white; - overflow: hidden; - } - - .landing-page { - position: relative; - width: 100%; - height: 100%; - display: flex; - justify-content: center; - align-items: center; - } - - .game-background { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: rgba(0, 0, 0, 0.7); /* Dark overlay */ - backdrop-filter: blur(8px); /* Apply blur effect to the background */ - z-index: -1; /* Ensures it's in the background */ - pointer-events: none; /* Prevent interaction with the blurred background */ - } - - .content { - text-align: center; - z-index: 1; /* Ensure content appears above the game background */ - padding: 20px; - max-width: 600px; /* Limit the width of the content */ - position: relative; - color: white; - backdrop-filter: blur(8px); /* Ensure content has some blur as well for contrast */ - } - - h1 { - font-size: 2rem; - margin-bottom: 20px; - } - - p { - font-size: 1.2rem; - margin-bottom: 30px; - } - - button { - padding: 12px 24px; - background-color: #ffcc00; - color: black; - border: none; - font-size: 18px; - cursor: pointer; - border-radius: 5px; - text-transform: uppercase; - transition: background-color 0.3s ease; - } - - button:hover { - background-color: #ff9900; - } - \ No newline at end of file diff --git a/styles.css b/styles.css index 15b329a..2849708 100644 --- a/styles.css +++ b/styles.css @@ -410,8 +410,4 @@ footer { height: 60px; width: 60px; } - - .project-name{ - font-size: 1.3em; - } }