Question

I'm looking for some good references for learning how to model 2d physics in games. I am not looking for a library to do it for me - I want to think and learn, not blindly use someone else's work.

I've done a good bit of Googling, and while I've found a few tutorials on GameDev, etc., I find their tutorials hard to understand because they are either written poorly, or assume a level of mathematical understanding that I don't yet possess.

For specifics - I'm looking for how to model a top-down 2d game, sort of like a tank combat game - and I want to accurately model (among other things) acceleration and speed, heat buildup of 'components,' collisions between models and level boundaries, and missile-type weapons.

Websites, recommended books, blogs, code examples - all are welcome if they will aid understanding. I'm considering using C# and F# to build my game, so code examples in either of those languages would be great - but don't let language stop you from posting a good link. =)

Edit: I don't mean that I don't understand math - it's more the case that I don't know what I need to know in order to understand the systems involved, and don't really know how to find the resources that will teach me in an understandable way.

Was it helpful?

Solution

Here are some resources I assembled a few years ago. Of note is the Verlet Integration. I am also including links to some open source and commercial physics engines I found at that time. There is a stackoverflow article on this subject here: 2d game physics?

Physics Methods

Books

  • "Game Physics Engine Development", Ian Millington -- I own this book and highly recommend it. The book builds a physics engine in C++ from scratch. The Author starts with basic particle physics and then adds "laws of motion", constraints, rigid-body physics and on and on. He includes well documented source code all the way through.

Physics Engines

OTHER TIPS

Speaking from experience, implementing a 2D physics engine is pretty difficult. I'll detail the several steps I took when creating my engine.

  1. Collision detection. Collision detection can be a difficult problem, even when you're not dealing with 3D worlds or networked simulations. For 2D physics, you definitely want to use the Separating Axis Theorem. Once you've implement SAT, you're half-way done making the dynamics portion of your engine.

  2. Kinematics/Dynamics. Chris Hecker has written an excellent online resource which walked me through collision response step-by-step.

  3. Everything Else. Once you've got the collision detection/response finished, its a matter of implementing everything else you want in the engine. This can include friction, contact forces, joints, along with whatever else you can think of.

Have fun! Creating your own physics simulation is an incredibly rewarding experience.

This is a great tutorial that demonstrates 2D physics concepts using flash and is not specific to flash. http://www.rodedev.com/tutorials/gamephysics/game_physics.swf

Even if you want to learn it all from the bottom up, an open source physics library that is well coded and documented contains far more information than a book. How do I deal with situation x... find in files can be faster than a paper index.

Original response:

What, no mention of Box2D? Its an open source side project of a blizzard employee, has a good community, and well, works great.

In my (brief) experience with Box2D, integrating it with Torque Game Builder, I found the API clean to use, documentation was clear, it supported all the physics objects I expected (joints in particular were a requirement), and the community looked friendly and active (sometime around early 2010).

Judging by forum posters, it also appeared that managers were receptive to source contributions (that did not carry license baggage).

It's island based solver seemed quite fast, as I expected from its reputation, not that I did any major performance testing.

F# has a feature called Units of Measure which does dimensional analysis for you, providing errors if you get it wrong. For example if you say:

let distance : float<meters> = gravity * 3.0<seconds>

That would yield a compile-error, since gravity is < meters/seconds^2 > and not < meters >. Also, since F# is just .NET you can write your math/physics code in a class library and reference that from your C#.

I'd reccomend you check out these blog posts for more information:

This is a great resource for writing your first engine. It's in 3D but it's very easy to convert down to 2D. I know at least one big company that followed this tutorial for their internal engine, and i personally have followed his steps for my own engine. He explains all the basic physics concepts in spring/impulse based physics, and shows you how to write your own intergrater.

The F#.NET Journal has published two articles about this:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top