This content originally appeared on DEV Community and was authored by Joseph Sen
I built a small 2D collision sandbox to visualize elastic collisions using Pygame for rendering and Pymunk (Chipmunk2D) for physics. A tiny Tkinter launcher lets you set the initial speeds and masses of two balls. The app then displays each ballβs live speed and the postβcollision speeds captured via a Pymunk post_solve callback.
Demo highlights
Set speed & mass for both balls before the sim starts (Tkinter dialog).
Realβtime physics with elasticity and friction; damping for subtle energy loss.
Onβscreen HUD: current speed (px/s) for each ball + speeds right after impact.
Static wall segments on both sides to keep objects in view.
Colorβcoded bodies: Green vs. Red.
This content originally appeared on DEV Community and was authored by Joseph Sen