More Chipmunk work today. I ported over demos 2, 3, and 4 to Ruby & Rubygame.
Demo 3 — 300 pentagons bouncing through a field of triangles, pachinko-style — ran a bit slowly, so I reduced it to 200. Since the C w/ OpenGL version of the demo runs just fine, I'm guessing the bottleneck here is the SDL drawing functions (300+ draws per frame can be a bit much). I'm sure the ruby binding isn't quite as fast as the native C, so that might be part of it as well. I might try using ruby-opengl for the demos, to more closely emulate the C demos, but that's not really a priority.
I'm getting a better grasp on how Chipmunk is used, which is nice. I'm currently pondering the different aspects of collision detection and response:
- Generating an event when objects collide.
- Responding physically when objects collide.
For any given colliding object, you might want one, both, or neither of those. Or you might only want them to occur under certain circumstances (e.g. collide with the floor, but not with other players). It can get complicated, but Chipmunk has some nice features to make it simpler, especially layers, groups, and types.
Tomorrow I'll port over the rest of the demos, and maybe make my own with those (in)famous pandas. Fun times!