Overview
Three balls moving along a line, bouncing off each other and off the walls at either end. Velocities after each impact come from conservation of momentum and the coefficient of restitution.
Masses, starting positions, velocities and elasticity are all set in the script, so the balls can be perfectly elastic or made to lose energy on every collision.
Stack
- Python
- PyGame