GarGerry commited on
Commit
cbff512
·
verified ·
1 Parent(s): fab2b64

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +9 -2
index.html CHANGED
@@ -41,6 +41,7 @@
41
  let ballPosition = { top: 0, left: Math.random() * 90 }; // Bola muncul secara acak.
42
  let isCaught = false; // Apakah bola ditangkap.
43
  let score = 0; // Skor awal.
 
44
 
45
  // Fungsi untuk memindahkan platform ke kiri
46
  function movePlatformLeft() {
@@ -85,7 +86,7 @@
85
  // Fungsi untuk menggerakkan bola
86
  function moveBall() {
87
  if (isCaught) return; // Jangan lanjut jika bola ditangkap.
88
- ballPosition.top += 0.8; // Bola turun lebih lambat
89
  ball.style.top = ballPosition.top + '%';
90
  ball.style.left = ballPosition.left + '%';
91
 
@@ -110,8 +111,14 @@
110
 
111
  // Fungsi untuk mereset permainan
112
  function resetGame() {
 
 
 
 
 
 
113
  isCaught = false;
114
- ballPosition = { top: 0, left: Math.random() * 90 }; // Bola muncul ulang.
115
  }
116
 
117
  // Fungsi untuk menampilkan overlay Game Over
 
41
  let ballPosition = { top: 0, left: Math.random() * 90 }; // Bola muncul secara acak.
42
  let isCaught = false; // Apakah bola ditangkap.
43
  let score = 0; // Skor awal.
44
+ let fallSpeed = 0.5; // Kecepatan bola turun lebih lambat.
45
 
46
  // Fungsi untuk memindahkan platform ke kiri
47
  function movePlatformLeft() {
 
86
  // Fungsi untuk menggerakkan bola
87
  function moveBall() {
88
  if (isCaught) return; // Jangan lanjut jika bola ditangkap.
89
+ ballPosition.top += fallSpeed; // Bola turun dengan kecepatan lambat
90
  ball.style.top = ballPosition.top + '%';
91
  ball.style.left = ballPosition.left + '%';
92
 
 
111
 
112
  // Fungsi untuk mereset permainan
113
  function resetGame() {
114
+ // Reset posisi platform dan bola
115
+ platformPosition = 50; // Platform kembali ke tengah
116
+ ballPosition = { top: 0, left: Math.random() * 90 }; // Bola muncul ulang
117
+ ball.style.left = ballPosition.left + '%';
118
+ ball.style.top = ballPosition.top + '%';
119
+ platform.style.left = platformPosition + '%';
120
  isCaught = false;
121
+ fallSpeed = 0.5; // Reset kecepatan bola
122
  }
123
 
124
  // Fungsi untuk menampilkan overlay Game Over