简体   繁体   English

用于C ++ 2D GameEngine的Chipmunk Physics或Box2D?

[英]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. 我正在开发它正在变成一个“跨平台”的2D游戏引擎,我的初始平台目标是iPhone OS,但可以转移到Android甚至某些控制台,如PSP或任天堂DS,我想保留我的选择打开。

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. 我的引擎是用C ++开发的,并且已经阅读了很多关于Box2D和Chipmunk的内容,但我还是无法决定使用哪一个作为我的物理中间件。

Chipmunk appears to have been made to be embedded easily, and Box2D seems to be widely used. Chipmunk似乎很容易嵌入,Box2D似乎被广泛使用。 Chipmunk is C , and Box2D is C++, but I've heard the API's of Box2D are much worse than chipmunk's API's. Chipmunk是C,而Box2D是C ++,但我听说Box2D的API比chipmunk的API差得多。

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 编辑 :我最后写了一篇关于我的特定选择的文章,你可以在这里找到它

I use both, but when I can choose, I go for chipmunk, it has much better API, and was much easier to learn... 我使用两者,但是当我可以选择时,我会选择花栗鼠,它有更好的API,并且更容易学习......

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". 更新:我目前的游戏是使用Box2D,我希望我使用Chipmunk ...主要是因为Box2D有两个严重的问题,在我的游戏中加剧了:首先,它有一个真正的旧错误,其中对象在角落“躲避” ,我的游戏是一个突破性的游戏,所以当球在墙上“滚动”时,有时会阻碍并从墙上甩开,很多人都会问为什么我的游戏物理看起来“随机”。

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. Box2D的其他问题是它如何存储对象,Chipmunk使用空间哈希,而Box2D使用二叉树,我的游戏在大量物体的水平上有很大的减速,我问Erin(Box2D的作者)的原因,他解释说因为Box2D使用二叉树,如果你把对象放在一个网格中(就像我说的那样,我的游戏是一个突破性的克隆!一切都在网格中!)树变得不平衡,Box2D变慢了。 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) 因此,对于所有基于图块的游戏,我将只使用Chipmunk,Box2D REALLY不适合那些(因为在瓷砖角落bug上的“障碍”,以及瓦片网格的减速错误)

You are right, chipmunk has been developed improving a lot of the places where Box2D falls down. 你是对的,花栗鼠已经开发出来,改善了很多Box2D倒塌的地方。

However, Box2D is definitely the more established platform and from my personal experience when making the decision of which engine to use, I found that Box2D had a much larger community following, so was easier to learn by example. 然而,Box2D绝对是更成熟的平台,根据我个人的经验,在决定使用哪种引擎时,我发现Box2D有一个更大的社区跟随,所以通过示例更容易学习。

Chipmunk is straight C, while Box2D is C++. Chipmunk是直的C,而Box2D是C ++。 There is also a new set of Objective-C bindings for Chipmunk, but they are not free to use commercially. Chipmunk还有一套新的Objective-C绑定 ,但它们不能免费使用。

As I understand it, Chipmunk does not support Continuous Collision Detection, but Box2D does. 据我了解,Chipmunk不支持连续碰撞检测,但Box2D支持。 This is important to prevent "tunneling" (objects passing slightly through eachother when moving at high speeds) 这对于防止“隧穿”(物体在高速移动时略微穿过彼此)非常重要

At the end of the day, from what I hear, they're both great. 在一天结束时,从我听到的情况来看,它们都很棒。 If you prefer C++ to C or need continuous collision detection, you should probably choose Box2D. 如果您更喜欢C ++到C或需要连续碰撞检测,您应该选择Box2D。

If you'd rather use a pure C library, go with Chipmunk. 如果您更喜欢使用纯C库,请使用Chipmunk。

I personally use Box2D and my experience has been fantastic so far. 我个人使用Box2D,到目前为止我的经验非常棒。

Also, I think Box2D has a different (possibly larger) set of joint types, so that could be something to consider... 另外,我认为Box2D有一组不同的(可能更大的)关节类型,所以可以考虑......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM