Rabbyt, Pymunk, and Pyglet
For this tutorial, we’re putting pygame and rabbyt on the back burner and focusing our attention on pymunk. Pymunk is a pythonic wrapper around the Chipmunk 2d physics library. In this tutorial we create a simulation in which we drop a ball on to a flat surface. As the simulation runs, we periodically print the ball’s height. Graphing this value against time gives us the following:
Astute readers will notice that the ball seems to bounce before it hits the floor. This is influenced by the value we pass to space.step. Calling space.step with a smaller value (i.e. higher resolution) would give us a more accurate graph. Of course, assuming we ran our higher resolution simulation for the same amount of time, we’d have a lot more values to graph.
In our next tutorial we’ll be combining pymunk, pyglet, and pygame and creating a full-fledged graphical physics simulation.