2d physics game?

Can someone point me to a library for the physics of 2D games, etc. for programming gravity, jumping actions, etc. for 2d platform / sidescrolling? Or you could suggest some algorithms for the side scroller, such as mario, sonic, etc.

+12
c ++ physics
Sep 19 '08 at 1:26
source share
11 answers

Looks like Chipmunk can meet your needs.

+22
Sep 19 '08 at 1:31
source share

Best of all, most likely Box2D . It performs 2D physics, has many options and is very easy to integrate into an existing project. By default, this is CCD for fixed bodies, but any solid can be selectively included in the calculation of CCD.

+12
Sep 19 '08 at 1:35
source share

If you need gravity, you can program it yourself after 5 minutes. Freely falling objects are accelerated at a speed of 9.8 meters per second per second, that is, an object downward speed increases by 9.8 meters per second of free fall. For the game you will want to divide this 9.8 into any frame rate you have. For jumping, simply select a significant negative vertical speed, apply this to the character the moment they jump, and reduce it by incrementing the gravity in each frame. This is really all you need for something like Mario, unless you are looking for a three-dimensional background for your 2d scroller.

If you want to become more attractive, you can try to take into account the force of the object, making the falling objects harmful people or cracks or something else. To do this, we use the formula for kinetic energy: KE = 1/2 * M * V ^ 2, where M is mass and V is velocity.

+9
Sep 19 '08 at 1:39
source share

What platform are you looking for? Which library you will use will depend on this.

For the XNA framework, Farseer is pretty nice.

+5
Sep 19 '08 at 1:29
source share

To answer the second part of your question, if you want to get an idea of ​​how a simple 2D platformer works, read the tutorials for H. Yes, N is a flash game-based game, but this does not mean that it is not built as a β€œreal” game, therefore collision detection exercises (and answers) are very applicable. They are easy to read with some intuitive demos built into the page to show geometric concepts.

+4
Sep 21 '08 at 19:02
source share

You can look at the Havok engine. I believe that they have released a free version for non-commercial use. There is a set of restrictions for this, which will allow you to limit the physics to two planes, in your case x and y.

+2
Sep 19 '08 at 1:32
source share

The physics in most 2D scrolling games for scrolling is so simple that you can easily implement them yourself. What effects are you looking for?

+2
Sep 19 '08 at 1:33
source share

If you have time that you could use PhysX, but most likely it is more than for 2D. Also, if you plan on making your game run on PC and you need some cool physics, try googling for "verbal integration." I know that there are quite a few verlet implementations (great for particles and two-dimensional rag dolls).

+2
Sep 19 '08 at 1:35
source share

I used Box2D in personal projects. This is a 2D physical simulation API. But maybe redundant if you want more gaming / graphics APIs.

+2
Sep 19 '08 at 1:35
source share

This guy has done a great job with Javascript games:

http://blog.nihilogic.dk/

+2
Sep 19 '08 at 2:29
source share

You can do 2d physics with opende as well

+2
Sep 21 '08 at 18:55
source share



All Articles