79226141

Date: 2024-11-26 09:58:50
Score: 0.5
Natty:
Report link

In your code snippet, you did

body.accY += 9.8 * delta * delta;

for your gravity, which is not in the pseudo code and also wrong (since you're multiplying it by delta squared twice now, once here and then another time in your final velocity calculation).

Another issue is your delta being too low. At higher timesteps, it's already 0.0003 at timestep 20 which, after being multiplied with itself, yields 8.999999999999999e-8 which I'm guessing is causing the speedup/slowdown due to low precision.

changing the delta line and gravity line to

let dt = elapsed / 100.0;

and

body.accY += 9.8;

respectively seems to keep the speed steady even at timesteps of over 100

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Filler text (0.5): 999999999999999
  • Low reputation (1):
Posted by: Gopher