P2.js is a lightweight JavaScript library that simulates 2D rigid-body physics. It handles bodies (shapes like boxes, circles, polygons), forces (gravity, velocity, angular momentum), collisions (detecting and resolving contact), and constraints (joints, springs, motors). Developers use P2 to build games where characters jump and fall, puzzles where blocks stack and tumble, or interactive visualizations where particles and objects behave like real physics. A typical flow: Create a world with gravity (9.8 m/s²). Add a player body (dynamic, affected by forces). Add a floor body (static, immovable). Update the world each frame (world.step(deltaTime)). P2 detects collision between player and floor, resolves it (player stops falling). Call an event listener when they collide.