Rooni commited on
Commit
f72f7ba
·
verified ·
1 Parent(s): 44aad89

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +6 -6
script.js CHANGED
@@ -5,7 +5,7 @@ const gameOverDisplay = document.getElementById('game-over');
5
  let score = 0;
6
  let gameOver = false;
7
  let orbSpeed = 2;
8
- let bonusSpeed = 3;
9
  let intervalId;
10
 
11
  // Player movement
@@ -38,7 +38,7 @@ function createOrb() {
38
  if (checkCollision(orb, player)) {
39
  clearInterval(interval);
40
  gameArea.removeChild(orb);
41
- score++;
42
  scoreDisplay.textContent = score;
43
  increaseDifficulty();
44
  }
@@ -65,7 +65,7 @@ function createBonus() {
65
  if (checkCollision(bonus, player)) {
66
  clearInterval(interval);
67
  gameArea.removeChild(bonus);
68
- score += 5; // Bonus gives 5 points
69
  scoreDisplay.textContent = score;
70
  }
71
  }, 16);
@@ -102,7 +102,7 @@ function startGame() {
102
  score = 0;
103
  scoreDisplay.textContent = score;
104
  orbSpeed = 2;
105
- bonusSpeed = 3;
106
  gameOverDisplay.style.display = 'none';
107
  gameOver = false;
108
  intervalId = setInterval(() => {
@@ -110,8 +110,8 @@ function startGame() {
110
  if (Math.random() < 0.1) { // 10% chance to create a bonus
111
  createBonus();
112
  }
113
- }, 1000);
114
  }
115
 
116
  // Start the game
117
- startGame();
 
5
  let score = 0;
6
  let gameOver = false;
7
  let orbSpeed = 2;
8
+ let bonusSpeed = 4;
9
  let intervalId;
10
 
11
  // Player movement
 
38
  if (checkCollision(orb, player)) {
39
  clearInterval(interval);
40
  gameArea.removeChild(orb);
41
+ score += 10;
42
  scoreDisplay.textContent = score;
43
  increaseDifficulty();
44
  }
 
65
  if (checkCollision(bonus, player)) {
66
  clearInterval(interval);
67
  gameArea.removeChild(bonus);
68
+ score += 50; // Bonus gives 50 points
69
  scoreDisplay.textContent = score;
70
  }
71
  }, 16);
 
102
  score = 0;
103
  scoreDisplay.textContent = score;
104
  orbSpeed = 2;
105
+ bonusSpeed = 4;
106
  gameOverDisplay.style.display = 'none';
107
  gameOver = false;
108
  intervalId = setInterval(() => {
 
110
  if (Math.random() < 0.1) { // 10% chance to create a bonus
111
  createBonus();
112
  }
113
+ }, 500); // Create orbs and bonuses every 500ms
114
  }
115
 
116
  // Start the game
117
+ startGame();