42

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.

Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
  • If you want to do it accurately, and want to do it yourself, but don't understand the math involved, there's not too much anyone can do for you. First you need to understand what you are trying to model before you can attempt to model it. – Matthew Scharley Oct 03 '08 at 02:19
  • 4
    Which is why I'm asking for resources on this subject..... =P – Erik Forbes Oct 03 '08 at 02:39
  • Ah... sorry, I think I misunderstood the question then, I thought you were asking for code samples on how to do it... Anyway, as I recall, we covered this sort of stuff in year 11 physics, perhaps picking up a textbook or two might be a good start. – Matthew Scharley Oct 03 '08 at 02:50
  • 1
    wiki has some links to books, etc. http://en.wikipedia.org/wiki/Game_physics – Robert Paulson Oct 03 '08 at 03:07
  • I have the same problems, it seems a lot of stuff requires a level of understanding on mathematics I don't yet have. But finding stuff on that is near impossible – Isaiah Oct 12 '11 at 22:20

8 Answers8

21

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

Community
  • 1
  • 1
mistrmark
  • 4,349
  • 6
  • 22
  • 15
  • 4
    I think this is the way physics should be taught in schools. Make your own game with the physics. –  Jan 14 '09 at 04:34
  • The second link (Advanced Character Physics) is broken; http://www.gamasutra.com/resource_guide/20030121/jacobson_01.shtml returns 404. =( – Erik Forbes Aug 12 '13 at 14:24
  • And here's an archive for the article - http://www.gamasutra.com/resource_guide/20030121/jacobson_pfv.htm – Erik Forbes Aug 12 '13 at 14:25
  • Found the actual article here - http://www.gamasutra.com/view/feature/131313/advanced_character_physics.php - but unfortunately the images don't display, so most of the math is missing. =( – Erik Forbes Aug 13 '13 at 15:16
8


(source: oreilly.com)

Physics for Game Developers by O'Reilly

Community
  • 1
  • 1
David Koelle
  • 20,726
  • 23
  • 93
  • 130
7

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.

epaik
  • 235
  • 2
  • 5
3

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

angelo
  • 482
  • 3
  • 6
  • 13
3

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.

James
  • 1,973
  • 1
  • 18
  • 32
  • 2
    here are some tips: provide a link. provide evidence, not opinion. personal experience works, but only if you give credence to your argument instead of just "[it] works great" – Chris MacDonald Jul 10 '09 at 17:20
  • 1
    Angry Birds come to mind. Box2D is legit. – ojrac Mar 05 '11 at 06:29
2

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:

Chris Smith
  • 18,244
  • 13
  • 59
  • 81
1

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.

DavidG
  • 1,796
  • 4
  • 21
  • 33
  • 1
    This is a great resource - make sure to check out his other articles on physics as well! – thekidder Oct 18 '08 at 17:48
  • 2
    That link is broken, this is where that content resides now: http://gafferongames.com/game-physics/spring-physics/ – batbrat May 08 '11 at 06:52
0

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

J D
  • 48,105
  • 13
  • 171
  • 274