Several forces act on a body at once, and last frame's forces must not linger into this one. Today you sum multiple forces and clear the accumulator each step.
Accumulate multiple applied forces into one net force and reset it to zero on demand.
Real motion comes from several forces at once - gravity pulling down, a contact
pushing up, maybe a spring or the wind. Because ApplyForce accumulates, calling it
repeatedly builds up the net force on the body: {3, 0} plus {0, 4} gives
{3, 4}, and dividing by mass gives the acceleration to integrate. This is the
force accumulator pattern, and it is how the world will let many independent
effects act on one body in a single frame.
The essential companion is clearing the accumulator after each step. Forces are
applied fresh every frame; if you never reset Force, last frame’s gravity would
add to this frame’s and the body would accelerate without bound. So a step is always
three beats: derive the acceleration from the accumulated force, integrate, then zero
the accumulator so the next frame starts clean. Pin that a cleared body with no new
force coasts at constant velocity.
// ApplyForce already adds into b.Force; clearing zeroes itfunc (b *Body) ClearForces() { b.Force = Vec2{} }// a full step: derive acceleration, integrate, then clear the accumulator// b.Acceleration = b.accelerationFromForce(); b.Integrate(dt); b.ClearForces()