I’m on a long personal journey to recreate classic games from scratch with my own flair to improve my programming skills. My next project is Asteroids, and I would like the asteroids to bounce off each other. I have been trying to wrap my head around elastic collision for some time now and I’m almost there.
Using the Elastic Collision page from Wikipedia I have recreated the Two-Dimension Collision equation. The result however, is subtly more like soap bubbles. I think the problem is how I’m handling the positions of the particles after they collide. I just can’t figure out what the problem is. Is anyone willing and able to take a look?
I have been looking at a few libraries, but I would really like to get this working without them. However, I highly appreciate the resources you’ve provided.
I’ve done some playing with the code, and if I move the particles farther from each other, there is a very obvious jitter that I can’t explain. After observing the behavior, I have noticed that the vertical collisions slide past each other rather than bounce off. So I’m checking the code again.