Skip to content

giorgosg/box2d-py

Repository files navigation

box2d-py

Python Bindings for Box2D v3 using CFFI

Documentation Status Build Status

Python bindings for the Box2D physics engine version 3. Provides Pythonic access to Box2D's feature set.

Installation

Install from source using pip

pip install "git+https://github.com/giorgosg/box2d-py.git"

To include the testbed:

pip install "box2d-python[testbed] @ git+https://github.com/giorgosg/box2d-py.git"

Or Install from pypi:

pip install box2d-python[testbed]

Running the Testbed

box2d-testbed

Example Usage

from box2d import World, Vec2
# Create physics world
world = World(gravity=(0, -9.81))
# Create static ground body
ground = world.new_body().static().position((0, -5)).box(1, 10).build()
# Create dynamic bodies
bodybuilder = world.new_body().dynamic().box(0.5, 0.5)
bodies = [bodybuilder.position((x, 5)).build() for x in range(-5, 5)]
# Simulation loop
for _ in range(60):
    world.step(1/60, 4)

Development Status

⚠️ Early development preview - API subject to change
Currently supports some of the Box2D v3.0 functionality with active development ongoing.

Full API Documentation | Box2D Project

About

Python Bindings for box2d v3

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-Box2D

Stars

Watchers

Forks

Packages

No packages published