Update index.html
Browse files- index.html +51 -10
index.html
CHANGED
|
@@ -3,19 +3,60 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Futuristic
|
| 7 |
-
<!-- Import Google Fonts -->
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Orbitron&display=swap" rel="stylesheet">
|
| 9 |
-
<!-- Link to External CSS -->
|
| 10 |
<link rel="stylesheet" href="style.css">
|
| 11 |
</head>
|
| 12 |
<body>
|
| 13 |
-
<
|
| 14 |
-
|
| 15 |
-
<
|
| 16 |
-
<p>Stay ahead with real-time stock updates and futuristic design!</p>
|
| 17 |
-
<button>Explore Stocks</button>
|
| 18 |
-
<iframe src="https://fnkffp.vercel.app/" allowfullscreen></iframe>
|
| 19 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
</body>
|
| 21 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Futuristic Catch Game</title>
|
|
|
|
|
|
|
|
|
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
</head>
|
| 9 |
<body>
|
| 10 |
+
<div class="game-container">
|
| 11 |
+
<div class="ball"></div>
|
| 12 |
+
<div class="platform"></div>
|
|
|
|
|
|
|
|
|
|
| 13 |
</div>
|
| 14 |
+
<script>
|
| 15 |
+
const platform = document.querySelector('.platform');
|
| 16 |
+
const ball = document.querySelector('.ball');
|
| 17 |
+
const gameContainer = document.querySelector('.game-container');
|
| 18 |
+
|
| 19 |
+
let platformPosition = 50; // Initial position of the platform (centered).
|
| 20 |
+
let ballPosition = { top: 0, left: Math.random() * 90 }; // Random horizontal start for the ball.
|
| 21 |
+
|
| 22 |
+
// Move platform
|
| 23 |
+
window.addEventListener('keydown', (e) => {
|
| 24 |
+
if (e.key === 'ArrowLeft' && platformPosition > 0) {
|
| 25 |
+
platformPosition -= 5; // Move left
|
| 26 |
+
}
|
| 27 |
+
if (e.key === 'ArrowRight' && platformPosition < 90) {
|
| 28 |
+
platformPosition += 5; // Move right
|
| 29 |
+
}
|
| 30 |
+
platform.style.left = platformPosition + '%';
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
// Move ball
|
| 34 |
+
function moveBall() {
|
| 35 |
+
ballPosition.top += 2; // Ball falls down
|
| 36 |
+
ball.style.top = ballPosition.top + '%';
|
| 37 |
+
ball.style.left = ballPosition.left + '%';
|
| 38 |
+
|
| 39 |
+
// Check for collision with platform
|
| 40 |
+
if (ballPosition.top >= 90 && Math.abs(ballPosition.left - platformPosition) < 10) {
|
| 41 |
+
alert('You caught the ball!');
|
| 42 |
+
resetGame();
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// Check if ball missed
|
| 46 |
+
if (ballPosition.top >= 100) {
|
| 47 |
+
alert('Game Over!');
|
| 48 |
+
resetGame();
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
requestAnimationFrame(moveBall);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// Reset game
|
| 55 |
+
function resetGame() {
|
| 56 |
+
ballPosition = { top: 0, left: Math.random() * 90 };
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
moveBall();
|
| 60 |
+
</script>
|
| 61 |
</body>
|
| 62 |
</html>
|