OzoneAsai commited on
Commit
2720565
·
verified ·
1 Parent(s): 2699a28

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +4 -2
script.js CHANGED
@@ -35,10 +35,12 @@ document.addEventListener('click', (event) => {
35
  World.remove(world, ball);
36
  plotGraphs();
37
  }
 
38
  const x = event.clientX;
39
  const y = event.clientY;
40
- const velocityX = Math.random() * 10 - 5; // -5から5のランダムな速度
41
- const velocityY = Math.random() * 10 - 5;
 
42
  ball = Bodies.circle(x, y, 20, { restitution: 0.8 });
43
  Matter.Body.setVelocity(ball, { x: velocityX, y: velocityY });
44
  World.add(world, ball);
 
35
  World.remove(world, ball);
36
  plotGraphs();
37
  }
38
+
39
  const x = event.clientX;
40
  const y = event.clientY;
41
+ const velocityX = parseFloat(document.getElementById('vx').value); // ユーザー入力の初速度X
42
+ const velocityY = parseFloat(document.getElementById('vy').value); // ユーザー入力の初速度Y
43
+
44
  ball = Bodies.circle(x, y, 20, { restitution: 0.8 });
45
  Matter.Body.setVelocity(ball, { x: velocityX, y: velocityY });
46
  World.add(world, ball);