A 2D physics engine built from scratch in C++ and SFML, based on the popular Java tutorial series by Coding Minecraft.
This project is a personal learning exercise to re-implement the "Coding a 2D Physics Engine in Java" tutorial series in modern C++. The goal is to gain a deeper understanding of physics simulation, C++ best practices, and project structure using CMake.
[A screenshot of a cool demo will go here later!]
Follow these steps to build and run the project locally.
- A C++17 compliant compiler (GCC, Clang, MSVC, etc.)
- CMake (version 3.16 or higher)
Note: SFML 3 is downloaded automatically by CMake during the configuration step.
- Clone the repo
git clone [https://github.com/The-H4CKER/physics-engine.git](https://github.com/The-H4CKER/physics-engine.git) cd physics-engine
- Create a build directory
mkdir build cd build
- Run CMake to configure the project
cmake ..
- Compile and build the executable
cmake --build .
The final executable will be located inside the build
directory.
- Core Primitives & Data Structures (Videos #2-3) — Includes
RigidBody
,AABB
,Circle
, andBox
classes. - Point vs. Shape Collision Detection (Video #4) — Functions to test if a point is inside a shape.
- Primitive vs. Primitive Collision Detection (Videos #5-7) — Intersection tests for all shape combinations.
- Physics Simulation & Gravity (Videos #8-9) — Implementation of the
PhysicsSystem
, forces, and gravity. - Impulse-based Collision Resolution (Videos #10-13) — Calculation of collision manifolds and application of impulses.
- Rotational Physics & Friction (Videos #14-16) — Adding torque, angular velocity, and friction.
- Constraints & Joints (Videos #17-19) — Connecting bodies with constraints.
- This project would not be possible without the excellent original Java tutorial series by Coding Minecraft on YouTube.