Why I wrote a wrapper since there were already pymunk for python? I started playing out with pymunk first, but after a long I wanted some convenience (in form of fixed bugs). I Decided to modify pymunk just a bit to add that convenience. My face was about when I looked inside that thing. It was all unclear mess with lots of unused or broken code. After modifying it a bit I concluded that it'd be much more convenient to just do it again from scratch by looking pieces from here and there. It's not perfect (probably right now has lots of broken features [haven't tested them! ]), and in amount of features I dropped to a certain subset I saw fit (after I'll get everything working and have a fine documentation, I'll start considering which to drop and pick up.
After I got the velocity function setters to action, I hit this weird thing: gravity vector coming to the velocity updater is zero! It doesn't harm my bindings though, since I don't necessarily need the gravity variable through the velocity updater. Here's some code from my examples:
Code: Select all
poly.collided = 0.0
@pendulum.set_velocity_func
def pendulum_update_velocity(body, gravity, damping, dt):
damping *= 0.95
body.reset_forces()
if poly.collided > 0.0:
n = body.local_to_world(Vec2d(-10000.0, 0)) * poly.collided
body.apply_force(n*body.m, Vec2d(0, 0))
poly.collided -= dt
body.v = body.v*damping + (grav + body.f * body.m_inv) * dt
body.w = body.w*damping + body.t * body.i_inv * dt
@space.collision_pair(0, 1)
def hammer_pack(something, hammer, contacts):
hammer.collided = 0.5
return True
The mercurial repository is there if you want to look in: http://bitbucket.org/cheery/ctypes-chipmunk/