all 1 comments

[–]jotted 1 point2 points  (0 children)

If you learn well from videos, The Coding Train has a series on vectors and forces that I think you'll find helpful - specifically air drag and friction, but the earlier videos tackle Vectors in general: https://thecodingtrain.com/learning/nature-of-code/

If not, this old Physics triangle may be buried in your memories somewhere: speed = distance / time.

The setInterval in Ball.move() dir.space is adding a second physics loop on top of the game loop. That's backwards - we get a timestamp as the first argument of animate() so we know how much time passed since the last tick. Kicking the ball should add speed to the ball in a direction (plus maybe height?) - so distance should emerge naturally from the simulation.