GarGerry commited on
Commit
4aa027b
·
verified ·
1 Parent(s): ac01c02

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +9 -6
index.html CHANGED
@@ -4,7 +4,7 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Futuristic Falling Ball Game</title>
7
- <link rel="stylesheet" href="style.css">
8
  </head>
9
  <body>
10
  <div class="game-container">
@@ -13,10 +13,10 @@
13
  <div id="score">Score: 0</div>
14
  <div id="level">Level: 1</div>
15
  <div id="lives">
16
- <span id="life1" class="life">♥️</span>
17
- <span id="life2" class="life">♥️</span>
18
- <span id="life3" class="life">♥️</span>
19
- <span id="life4" class="life">♥️</span>
20
  </div>
21
  </div>
22
 
@@ -91,17 +91,20 @@
91
  let ballRect = ball.getBoundingClientRect();
92
  let platformRect = platform.getBoundingClientRect();
93
 
 
94
  if (ballY + 30 >= platformRect.top && ballY + 30 <= platformRect.bottom) {
95
  if (ballX + 30 >= platformRect.left && ballX <= platformRect.right) {
96
  // Ball hits the platform
97
  currentScore++;
 
 
 
98
  if (currentScore % 10 === 0) {
99
  level++;
100
  levelDisplay.innerHTML = "Level: " + level;
101
  fallSpeed -= 0.2;
102
  ballSpeed += 0.1; // Make ball fall faster
103
  }
104
- score.innerHTML = "Score: " + currentScore;
105
  resetBall();
106
  }
107
  } else if (ballY >= window.innerHeight) {
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Futuristic Falling Ball Game</title>
7
+ <link rel="stylesheet" href="style.css"> <!-- Link ke file CSS terpisah -->
8
  </head>
9
  <body>
10
  <div class="game-container">
 
13
  <div id="score">Score: 0</div>
14
  <div id="level">Level: 1</div>
15
  <div id="lives">
16
+ <span class="life" id="life1">♥️</span>
17
+ <span class="life" id="life2">♥️</span>
18
+ <span class="life" id="life3">♥️</span>
19
+ <span class="life" id="life4">♥️</span>
20
  </div>
21
  </div>
22
 
 
91
  let ballRect = ball.getBoundingClientRect();
92
  let platformRect = platform.getBoundingClientRect();
93
 
94
+ // Cek jika bola mengenai platform
95
  if (ballY + 30 >= platformRect.top && ballY + 30 <= platformRect.bottom) {
96
  if (ballX + 30 >= platformRect.left && ballX <= platformRect.right) {
97
  // Ball hits the platform
98
  currentScore++;
99
+ score.innerHTML = "Score: " + currentScore;
100
+
101
+ // Level Up Logic
102
  if (currentScore % 10 === 0) {
103
  level++;
104
  levelDisplay.innerHTML = "Level: " + level;
105
  fallSpeed -= 0.2;
106
  ballSpeed += 0.1; // Make ball fall faster
107
  }
 
108
  resetBall();
109
  }
110
  } else if (ballY >= window.innerHeight) {