Bouncy Balls v2: Learning Physics Through a Deliberately Unstable Simulation
Motion gets interesting when a system refuses to settle down. That was the idea here. Not realism. Not a serious physics engine. I wanted to see what happened if a few simple collision rules kept injecting energy back into the system instead of letting it stabilize.
The project is small. One file. Ten balls. An 800 by 600 window. But it was one of the first times I saw how simple rules can create behavior that feels unpredictable.
Simple Rules, Unexpected Behavior
Each ball had a random position, velocity, radius, and color. They bounced off walls, checked collisions against every other ball, swapped velocities, then sped up by ten percent on impact. That last part breaks physics. It was intentional.
Without that feedback loop, the simulation was much less interesting to watch. With it, collisions pushed the system into chaos. Balls started moving in patterns I did not script directly. That was the part that stuck with me.
One small detail I liked was using radius in the wall collision checks so collisions happened at the edge of the ball, not the center. Tiny thing. It made the motion feel much cleaner.
The Technical Tradeoff
The collision model was simplified. I used velocity swapping as an equal mass approximation because it was easy to reason about and easy to implement. For ten balls, even O(N squared) collision checks were fine.
- Collision response was simple enough to stay readable while still looking believable
- Processing collisions twice was inefficient, but acceptable at this scale
- Hard coded parameters made experimentation easy, even if the structure was rough
That tradeoff mattered. This was less about building a correct simulator and more about understanding the game loop, collision detection, and state updates running frame by frame at sixty FPS.
What Did Not Work
Fast moving balls could tunnel through each other. Overlapping collisions were not resolved well. As speeds climbed, the simulation could get messy for reasons that had nothing to do with interesting emergence and everything to do with naive physics.
I would also separate simulation logic from rendering if I rebuilt it. Everything living in one file was fine at ninety lines, but it does not scale. Even then I could feel the limits.
What It Taught Me
This was an early project, and it looked like one. That is part of why I still like it. It taught me that a small experiment can still reveal real engineering ideas. Approximation, feedback systems, performance tradeoffs, emergent behavior.
Sometimes ten bouncing circles are enough to teach the point.