Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chipmunk Physics or Box2D for C++ 2D GameEngine?

I'm developing what it's turning into a "cross-platform" 2D Game Engine, my initial platform target is iPhone OS, but could move on to Android or even some console like the PSP, or Nintendo DS, I want to keep my options open.

My engine is developed in C++, and have been reading a lot about Box2D and Chipmunk but still I can't decide which one to use as my Physics Middleware.

Chipmunk appears to have been made to be embedded easily, and Box2D seems to be widely used. Chipmunk is C , and Box2D is C++, but I've heard the API's of Box2D are much worse than chipmunk's API's.

For now I will be using the engine shape creation and collision detection features for irregular polygons (not concave).

I value:

1) Good API's
2) Easy to integrate.
3) Portability.

And of course if you notice anything else, I would love to hear it.

Which one do you think that would fit my needs better ?

EDIT: I ended up writing an article about my particular choice, you can find it here

like image 664
Goles Avatar asked Apr 25 '10 04:04

Goles


1 Answers

I use both, but when I can choose, I go for chipmunk, it has much better API, and was much easier to learn...

But that was because I learned it without need for a community, the manual is completly fine.

UPDATE: My current game is using Box2D, and I wish I used Chipmunk with it... Mostly because Box2D has two serious issues, that are exacerbated on my game: First, it has a REALLY OLD bug where objects "snag" on corners, my game is a breakout game, so when the ball is "rolling" along a wall, sometimes it snag and is flung away from the wall, lots of people asked why my game physics looks "random".

The other issues that Box2D have, is how it store objects, Chipmunk use a spatial hash, and Box2D use a binary tree, my game was having MASSIVE slowdowns in levels with lots of objects, I asked Erin (author of Box2D) the reason, and he explained that because Box2D uses binary tree, if you place objects in a grid (like I said, my game is a breakout clone! everything is in a grid!) the tree gets unbalanced, and Box2D slows down. The solution for my game was make some levels into a "checkerboard" pattern to avoid this problem.

So, for all tile-based games, I will just use Chipmunk, Box2D REALLY is unsuitable for those (because the "snag" on tile corner bug, and the slowdown bug with tile grid)

like image 139
speeder Avatar answered Oct 28 '22 02:10

speeder