2D Physics Simulation

About a year ago, I made a simple 2D rigid body physics simulator in C using SDL and some other libraries. This turned out to be a bit too hard and I got stuck on the collision response part. Besides that the whole thing was not designed well and just messy and ugly.

Because of that, I recently decided to completely remake it, and this time I started with circles instead of polygons. I chose that because it's so much easier to do collision detection and response for circles than it is for any other shape.

I also wanted to keep it cross-platform and portable, so I used OpenGL within SDL to do all the drawing.

Here are a few youtube videos showing the current capabilities of my physics engine:

The red arrows indicate the direction and size of the gravity force on each ball. In the first video you can also see that the green ball is more bouncy. It keeps gaining velocity until it shoots through the wall.

The source code of the current version (with the layout that's visible in the first video), is downloadable here: simple2d.tar.gz. Just run 'make' and it will compile.