GarGerry commited on
Commit
1936e7d
·
verified ·
1 Parent(s): f5f4767

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +20 -162
index.html CHANGED
@@ -3,170 +3,28 @@
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 class="score-board">Score: <span id="score">0</span></div>
14
- <div class="lives">Lives: <span id="lives">3</span></div>
15
- </div>
16
- <div class="controls">
17
- <button id="left-button">◀</button>
18
- <button id="right-button">▶</button>
19
- <button id="pause-button">Pause</button>
20
- </div>
21
-
22
- <!-- Game Over message -->
23
- <div class="game-over-message">
24
- <h2>Game Over!</h2>
25
- <p>Final Score: <span id="final-score"></span></p>
26
- <button id="restart-button">Restart</button>
27
- </div>
28
-
29
- <script>
30
- const platform = document.querySelector('.platform');
31
- const ball = document.querySelector('.ball');
32
- const leftButton = document.getElementById('left-button');
33
- const rightButton = document.getElementById('right-button');
34
- const scoreDisplay = document.getElementById('score');
35
- const livesDisplay = document.getElementById('lives');
36
- const pauseButton = document.getElementById('pause-button');
37
- const gameContainer = document.querySelector('.game-container');
38
- const gameOverMessage = document.querySelector('.game-over-message');
39
- const finalScoreDisplay = document.getElementById('final-score');
40
- const restartButton = document.getElementById('restart-button');
41
-
42
- let platformPosition = 50; // Posisi platform di tengah
43
- let ballPosition = { top: 0, left: Math.random() * 90 }; // Bola mulai di posisi acak
44
- let score = 0; // Skor
45
- let lives = 3; // Nyawa
46
- let isCaught = false; // Status tangkap bola
47
- let gamePaused = false; // Status pause
48
- let ballSpeed = 2; // Kecepatan bola
49
- let level = 1; // Level permainan
50
- let timer = 30; // Timer permainan
51
-
52
- // Pause Functionality
53
- pauseButton.addEventListener('click', () => {
54
- gamePaused = !gamePaused;
55
- if (gamePaused) {
56
- pauseButton.textContent = 'Resume';
57
- } else {
58
- pauseButton.textContent = 'Pause';
59
- moveBall(); // Continue game after pause
60
- }
61
- });
62
-
63
- // Fungsi untuk memindahkan platform ke kiri
64
- function movePlatformLeft() {
65
- if (platformPosition > 0) {
66
- platformPosition -= 5;
67
- }
68
- platform.style.left = platformPosition + '%';
69
- }
70
-
71
- // Fungsi untuk memindahkan platform ke kanan
72
- function movePlatformRight() {
73
- if (platformPosition < 90) {
74
- platformPosition += 5;
75
- }
76
- platform.style.left = platformPosition + '%';
77
- }
78
-
79
- // Kontrol tombol
80
- leftButton.addEventListener('click', movePlatformLeft);
81
- rightButton.addEventListener('click', movePlatformRight);
82
-
83
- // Fungsi untuk menggerakkan bola
84
- function moveBall() {
85
- if (gamePaused) return; // Jangan jalankan permainan jika di-pause
86
-
87
- ballPosition.top += ballSpeed;
88
- ball.style.top = ballPosition.top + '%';
89
- ball.style.left = ballPosition.left + '%';
90
-
91
- // Deteksi tabrakan
92
- if (ballPosition.top >= 90 && Math.abs(ballPosition.left - platformPosition) < 10) {
93
- isCaught = true;
94
- score++;
95
- scoreDisplay.textContent = score;
96
- resetBall();
97
- }
98
-
99
- // Game Over jika bola jatuh tanpa ditangkap
100
- if (ballPosition.top >= 100) {
101
- if (!isCaught) {
102
- lives--;
103
- livesDisplay.textContent = `Lives: ${lives}`;
104
- if (lives <= 0) {
105
- showGameOver(); // Tampilkan Game Over
106
- }
107
- }
108
- resetBall();
109
- }
110
-
111
- updateLevel(); // Perbarui level setelah mencapai skor tertentu
112
- requestAnimationFrame(moveBall);
113
- }
114
-
115
- // Fungsi untuk mereset bola
116
- function resetBall() {
117
- isCaught = false;
118
- ballPosition = { top: 0, left: Math.random() * 90 };
119
- }
120
-
121
- // Fungsi untuk memperbarui level
122
- function updateLevel() {
123
- if (score >= level * 10) {
124
- level++;
125
- ballSpeed += 0.5; // Meningkatkan kecepatan bola setiap level
126
- }
127
- }
128
-
129
- // Fungsi untuk reset permainan
130
- function resetGame() {
131
- score = 0;
132
- lives = 3;
133
- level = 1;
134
- ballSpeed = 2;
135
- timer = 30;
136
- scoreDisplay.textContent = score;
137
- livesDisplay.textContent = `Lives: ${lives}`;
138
- finalScoreDisplay.textContent = score;
139
- levelDisplay.textContent = `Level: ${level}`;
140
- timerDisplay.textContent = `Time: ${timer}s`;
141
- gameOverMessage.style.display = 'none'; // Sembunyikan Game Over
142
- resetBall();
143
- moveBall(); // Mulai kembali permainan
144
- }
145
-
146
- // Fungsi untuk menampilkan Game Over
147
- function showGameOver() {
148
- gameContainer.style.display = 'none'; // Sembunyikan konten permainan
149
- gameOverMessage.style.display = 'block'; // Tampilkan Game Over
150
- }
151
-
152
- // Fungsi untuk timer
153
- function countdownTimer() {
154
- if (!gamePaused && timer > 0) {
155
- timer--;
156
- timerDisplay.textContent = `Time: ${timer}s`;
157
- } else if (timer <= 0) {
158
- alert('Game Over! Time is up.');
159
- resetGame();
160
- }
161
- }
162
-
163
- // Update timer setiap detik
164
- setInterval(countdownTimer, 1000);
165
-
166
- // Restart game ketika tombol restart diklik
167
- restartButton.addEventListener('click', resetGame);
168
-
169
- moveBall(); // Memulai permainan
170
- </script>
171
  </body>
172
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Futuristic Game Theme</title>
7
  <link rel="stylesheet" href="style.css">
8
  </head>
9
  <body>
10
+ <header>
11
+ <div class="logo">Futuristic Game</div>
12
+ <nav>
13
+ <a href="#">Home</a>
14
+ <a href="#">Start</a>
15
+ <a href="#">Settings</a>
16
+ <a href="#">Leaderboard</a>
17
+ </nav>
18
+ </header>
19
+
20
+ <section class="hero">
21
+ <h1>Welcome to the Future</h1>
22
+ <p>Embark on an intergalactic adventure with futuristic graphics and gameplay.</p>
23
+ <button class="start-btn">Start Game</button>
24
+ </section>
25
+
26
+ <footer>
27
+ <p>&copy; 2025 Futuristic Game. All Rights Reserved.</p>
28
+ </footer>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  </body>
30
  </html>