+ 2

What is wrong with this code (JavaScript)?

Hello! I am trying to simulate a 2d solar system with gravitation pull using Newton's law. I am having trouble implementing it- atm the gravity seems to be working the opposite as I want it to and any adjustments I make seem to disable the pull. May you please help me understand how I can implement this so that bigger planets pull smaller bodies? Thank you! (Problem is line 30-40 ish I think) https://code.sololearn.com/Wa13a25A1860/?ref=app

23rd Mar 2021, 2:50 AM
Cam UOR
Cam UOR - avatar
2 ответов
+ 1
https://code.sololearn.com/WAHqLUAab5Pc/?ref=app I don't know why this work but I think it does, in line 40 I just changed g with -g
29th Mar 2021, 8:43 AM
Stefano De Angelis
Stefano De Angelis - avatar
- 1
ghgh
30th Mar 2021, 5:30 PM
Eldar Abylaisov