Physics Makes Games Feel Real
When a crate slides down a ramp in Half-Life 2, when birds smash into pig fortresses in Angry Birds, when cars crumple in BeamNG.drive — physics engines are doing the work. At their core, these engines solve Newton's equations of motion in real time: F=ma for acceleration, impulse-momentum for collisions, and constraint solvers for joints and contacts. This simulator demonstrates the fundamental building blocks.
The Simulation Loop
Every frame, the physics engine performs the same steps: apply forces (gravity, player input), integrate to get new positions, detect collisions, resolve interpenetrations, and apply impulses to change velocities. This cycle repeats 60 times per second (or more — many engines run physics at a fixed timestep of 120Hz or 240Hz for stability). The time scale slider lets you slow this loop to observe individual collisions in detail.
Collision Detection and Response
Detecting whether two circles overlap is simple: check if the distance between centers is less than the sum of radii. The response is more nuanced. The collision normal determines the direction of the impulse. The coefficient of restitution determines how much velocity is reflected. Friction removes tangential velocity. Together, these three factors determine whether a collision looks like a bouncing ball, a sliding hockey puck, or a crumpling car.
Energy Conservation and Dissipation
In a perfect system (restitution=1, friction=0), total kinetic energy is conserved and objects bounce forever. Real systems lose energy through inelastic deformation (restitution < 1) and friction (converting kinetic energy to heat). This simulation tracks total kinetic energy over time, letting you see how quickly energy dissipates for different material properties — and why all physical systems eventually come to rest.