Project 04 · C++ / Simulation

2D Physics Engine

A real-time rigid-body simulation with impulse-based collisions and configurable forces.

Role
Solo project
Timeline
Apr — Jul 2025
Stack
C++ · SFML
Status
Completed

01 / Engine

Build the mechanics to understand the mechanics.

The engine simulates rigid bodies in real time and renders the result with SFML. Instead of relying on an existing physics library, I implemented the integration and collision response directly.

  • Newtonian integration per body and frame.
  • Impulse-based collision resolution using mass and restitution.
  • Configurable restitution, drag and gravity.

02 / Demonstration

Interactive controls make the parameters visible.

At runtime, objects can be added dynamically, gravity can be toggled and static obstacles can be introduced. Changing restitution, drag and gravity makes their effects visible immediately instead of hiding them behind a fixed demonstration.

03 / Explanation

Resolve each impact as a change in momentum.

For each collision, the engine determines the contact normal and relative velocity, then applies an impulse based on the bodies’ masses and restitution. This changes velocity without relying on a third-party physics library.