maringetxway commited on
Commit
bd2551d
·
verified ·
1 Parent(s): 03b8b16

Update stars.js

Browse files
Files changed (1) hide show
  1. stars.js +8 -7
stars.js CHANGED
@@ -12,21 +12,21 @@ function createStars(count) {
12
  stars = [];
13
  for (let i = 0; i < count; i++) {
14
  stars.push({
15
- x: Math.random() * canvas.width,
16
- y: Math.random() * canvas.height,
17
  z: Math.random() * canvas.width,
18
  });
19
  }
20
  }
21
 
22
  function moveStars() {
23
- const speed = 2;
24
  for (let i = 0; i < stars.length; i++) {
25
  stars[i].z -= speed;
26
  if (stars[i].z <= 0) {
27
  stars[i].z = canvas.width;
28
- stars[i].x = Math.random() * canvas.width;
29
- stars[i].y = Math.random() * canvas.height;
30
  }
31
  }
32
  }
@@ -58,9 +58,10 @@ function animate() {
58
 
59
  window.addEventListener("resize", () => {
60
  resizeCanvas();
61
- createStars(500);
62
  });
63
 
 
64
  resizeCanvas();
65
- createStars(500);
66
  animate();
 
12
  stars = [];
13
  for (let i = 0; i < count; i++) {
14
  stars.push({
15
+ x: Math.random() * canvas.width - canvas.width / 2,
16
+ y: Math.random() * canvas.height - canvas.height / 2,
17
  z: Math.random() * canvas.width,
18
  });
19
  }
20
  }
21
 
22
  function moveStars() {
23
+ const speed = 8; // Was 2 — now way faster!
24
  for (let i = 0; i < stars.length; i++) {
25
  stars[i].z -= speed;
26
  if (stars[i].z <= 0) {
27
  stars[i].z = canvas.width;
28
+ stars[i].x = Math.random() * canvas.width - canvas.width / 2;
29
+ stars[i].y = Math.random() * canvas.height - canvas.height / 2;
30
  }
31
  }
32
  }
 
58
 
59
  window.addEventListener("resize", () => {
60
  resizeCanvas();
61
+ createStars(1000); // Double the star count
62
  });
63
 
64
+
65
  resizeCanvas();
66
+ createStars(1000);
67
  animate();