Should I go chipmunk or Box2D?

Forums Programming physics: Box2d, Chipmunk et al Should I go chipmunk or Box2D?

This topic contains 10 replies, has 6 voices, and was last updated by  Nyvaken 3 years, 10 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
Author Posts
Author Posts
June 4, 2010 at 2:33 pm #222178


Hi, I’m working on a tank game where the player views and controls a tank from above. I want to add some physics such as collision. When i collide with certain object i want them to respond naturally, to be rotated in a natural way etc.

This video shows a similar game with the physics I want to achieve (Collision with enemy tanks and the yellow bits).

I started out with a normal cocos2d Application project. Should I stick to this or choose any of the other?

Any help is highly appreciated! :)

June 4, 2010 at 2:57 pm #285342


Personally, I like Chipmunk because it is written in C, which I am most familiar with. It also has a good wrapper called SpaceManager.

The good parts of Box2D are that it supports bullets better, but in your preview it doesn’t seem like you have any super fast bullets travelling. Box2D is written in C++ so if you like that language better, it may be easier.

Your game looks AMAZING though. The sounds, interface, graphics, gameplay, it all looks amazing. Quite honestly I see it in the top 10.

How did you achieve the smooth scrolling around the map?

June 4, 2010 at 3:01 pm #285343


It’s a hard choice. Anyone who uses Box2D will say it’s better whilst people who use Chipmunk will say it’s better.

I think it ultimately comes down to which you like more. The “liking” can come in many different forms, from the languages they are both based on to functionality found within.

Personally, I like Box2D.

I find it to be a more established engine. It has a larger community, and thusly it’s easier to find support and examples for. It’s also based on C++, versus Chipmunk being based in C. I like C++ more and find it easier to work with in some cases. You can get screwed over with memory allocation easily, but if you take care of your code you’ll be fine. Another major influence is that I really don’t like the way Chipmunk’s code looks. The “cp” prefix throws me off, and the code itself doesn’t look that beautiful. While Box2D takes time to get used to, as it definitely is confusing, it’s easy to work with after some experience.

Then again, I’m a Box2D guy… So everything I said is biased. I’m sure a Chipmunk fan can walk in and disagree with everything I’ve said.

Again, it ultimately comes down to what YOU like. Try both. Create example projects for both engines, look through the test and example files. Search for tutorials: Which engine has blogs/articles that might be able to help you out the most? Try to see yourself typing that code out yourself: Is it comfortable? Can you invision yourself writing that from scratch?

Just play around, and you’ll find the engine that’s right for you.


June 4, 2010 at 3:02 pm #285344


That’s not my game, it’s just a similar game, as I mentioned before :P

Thanks for the tip! I will look into Chipmunk because I’m not familiar with c++.

June 4, 2010 at 3:05 pm #285345


Thanks Robodude,

I will google them both, try some example and see which of them fits my project best.

June 4, 2010 at 3:41 pm #285346


I’m a fan of Chipmunk, but mostly because I’d much rather deal with C than C++. I agree that you should check out both, play the their sample code, and go with the one that feels the most intuitive to you.

June 4, 2010 at 4:07 pm #285347


@Nyvaken Oops I probably should have read your post better.

Like I and others have said, it basically comes down to C versus C++. Robo is right, Box2D is more mature and has more examples though.

I still would advise looking into SpaceManager though.

June 4, 2010 at 4:10 pm #285348


I have now successfully changed my project to a Chipmunk project. Everything works as usual and i’ve been eyeing some Chipmunk code now for an hour.

As I understand it, I have to make 3 things for every object: A sprite, a body and a shape. Is this correct?

I also assume that the static void eachShape(void *ptr, void* unused) method is what I will have to work with the most. Im having trouble using my own variables inside this method. It says they are undeclared.

June 4, 2010 at 4:54 pm #285349


seems like you’ve picked chipmunk… did you take a look at Spacemanager? it’s a very very nice wrapper around chipmunk that makes it way easier to setup/manage, IMHO with Objective C / Cocos2d specific functionality… it’s managed by @mobilebros that’s constantly on these forums too…

basically, since your still early in your integration efforts, i’d suggest checking it out, big time!

June 4, 2010 at 6:30 pm #285350


In case you do go the SpaceManager route, here’s a lil blog post from this site discussing a quick example.

June 5, 2010 at 9:47 am #285351


Awesome, you guys have been very helpful!! Thanks a lot :)

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.