Clone wiki

pysics / Home


Pysics is a pythonic Box2D wrapper under development. It is currently implemented as a secondary wrapper on top of pyBox2D, though in the future it may wrap Box2D directly, probably using Boost.Python. The goals for Pysics are:

  • Pythonic API for Box2D.
  • Flexible and safe.
  • Minimize repetitive coding.

Changes from the C++ interface

  • Python/pyglet naming conventions. Remove b2 prefix. NameClassesLikeThis, name_the_rest_like_this.
  • Instantiate Python classes directly, e.g. Body(world=world, ...) instead of world.CreateBody(...)
  • Destroy instances with e.g. body.delete() instead of world.DestroyBody(body)
  • Check if an instance has a physics representation with e.g. body.physical
  • Eliminate def classes in favor of kwargs.
  • Eliminate fixture classes. Use shape.body = body or Body(shapes=[shape]) to attach a shape to a body.
  • Prevent crashes when e.g. accessing a destroyed body.

Differences to pyBox2D

pyBox2D is a straight SWIG wrapper of Box2D with some additions like Python properties. It currently serves as the bottom layer of Pysics. As of January 2010, the author of pyBox2D is further improving ease of use.

Pysics will not be a straight Python wrapper of Box2D with additions, but rather a simplified representation of Box2D in Python.