A 2D physics sandbox written in C++ using OpenGL's immediate-mode API and GLFW for window and input management, built with CMake and targeting Linux/X11. The simulation renders colored circles and rectangular blocks inside a resizable window with a physics engine written from scratch.
Each ball carries position, velocity, and mass. Per-frame dynamics apply gravity, air drag, and a coefficient of restitution and friction that govern how balls bounce and slide on impact. Ball-to-ball collisions use an impulse-based formula with midpoint separation to prevent overlap. Ball-to-block collisions reflect velocity off whichever face is struck. To handle many-body pileups more stably, the engine runs 25 collision-resolution passes per frame.
A fun quirk of the implementation: physically moving or shaking the OS window imparts impulse to every ball in the scene, so you can fling them around by dragging the window. Spawning is fully interactive, with left-click launches a ball with velocity matching your mouse swipe, H drops a stationary ball at the cursor, G drops one moving left, and X places a static rectangular block. All colors are randomized on spawn.