Hey, I'm working on something like this: https://www.youtube.com/watch?v=MH03ZJaNe8A
I'm having trouble with the balls staying lined up. I made a simple example with just 2 balls to test my problem, and in no time, they start to stray from where they should be.
In my test, I have 2 balls bouncing off the left and right of the window. The top ball is twice as fast as the bottom ball, so they should still line up every other bounce.
I have included a video of what it looks like, and you can see they don't maintain their true position.
Here also is the part of the code that contains the ball positioning:
I think it might be floating point errors but I'm not sure.
Any ideas how to fix this?
Here also is the part of the code that contains the ball positioning: