🎯 Pygame + Pymunk Collision Lab β€” tweak mass & speed, watch the physics happen



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