Hello, I'm making a simple gravity simulator for my science class and I ran into an issue. The program has the user enter the individual masses of two balls aswell as the distance between the two. It then calculates the gravitational attraction between the two and uses that to (hopefully) move the objects closer to each and repeats using the new distance. Here is a picture of the current interface if it helps:
My issue is that the balls aren't moving properly. The balls will hit eac other before the distance reaches 0 (technically 66.5 pixels apart since like normal solids, they phase through each other). The screen is 550 pixels wide and each ball has a diameter of 66.5 pixels. I'm fairly ertain the issue is from converting the distance (in meters of course) being used for the calculations to pixels so that the balls move realistically. Any advice as to how I could fix this?
P.S. I'm aware that gravity dosen't change over set intervals, and my teacher said its fine that it changes over the second rather than instantaneously.