Box2D by Erin Catto, the world's best 2D physics engine now becomes a built-in module in pkpy
v1.1.3 and later.
box2d module will be enabled by default for CMake users.
All platforms are supported, including desktop, mobile and web.
You can set option
OFF in CMakeLists.txt
if you don't want to use it.
box2d module in pkpy provides a high-level, also simplified, interface to Box2D engine, which is suitable for most use cases.
There are two classes in
World is the world of Box2D, it is the container of all
In most cases, you only need one
World class provides methods to create, destroy and query
and also methods to step the simulation.
Body instance is a physical entity in the world.
Body can only have one shape at a time.
For example, a circle, a rectangle, a polygon, etc.
You are allowed to change the shape of a
Body at runtime.
Bodys can be static, dynamic or kinematic.
Body is not affected by forces or collisions.
Body is fully simulated.
Body moves according to its velocity.
Body class provides methods to set its properties, such as position, velocity, etc.
It also provides methods to apply forces and impulses to it.
box2d.Body in pkpy is an unified wrapper of Box2D's
It hides the details of Box2D's API and provides a high-level interface.
import box2d world = box2d.World() body = box2d.Body(world)