2d Platformer physics

FlySwat picture FlySwat · Dec 2, 2008 · Viewed 12k times · Source

It was a long holiday weekend, so I got the coding bug again and started playing around:

Mario http://gfilter.net/junk/tileengine.jpg

I wrote a basic tile engine, but having never attempted this before, I am really struggling with handling sprite collision detection and implementing realistic physics for gravity.

For any other game hobby writers, can you point me towards some walkthroughs on the best way to approach this?

Update:

I thought I'd share a progress report:

http://www.youtube.com/watch?v=-RKNQ2UiiLY <-- Game in Action

Its still really buggy, but collision detection is mostly working, I've started working on some other features (such as bumping the blocks (notice the bug) and interacting with the enemies).

Mario still walks like he is on the moon, I'm using these constants, any advice for tweaking them for more realism?

    const float AirDrag = 1.00f;
    const float GroundFriction = .97f;
    const float Gravity = 0.8f;

Answer

Tablet picture Tablet · Dec 2, 2008

Download the FarseerPhysics engine, have a look at how it works http://www.codeplex.com/FarseerPhysics I think it's the best thing available for XNA/Silverlight!