Category Archives: Javascript

Tracking Missile in Box2D

If you have been playing around with Box2D then chances are you have already figured out how to simulate linear projectile motion or maybe even tried to simulate arrow flight. These are all great places to start, but maybe you are looking for something more advanced? How about a projectile that scans for targets and when it has locked on to one follows it to the bitter end? Continue reading Tracking Missile in Box2D

Simulating Multiple Sources of Gravity in Box2D

Simulating a single source of gravity is a sinch in ¬†Box2D. You can even switch gravity off if you like. But what about simulating multiple gravity sources, like planets? This isn’t as hard as it sounds, but requires some additional work. Something to consider is that when simulating radial gravity, or planet gravity, we don’t work with the same scales as in, um, the universe. Instead of orbits that are thousands kilometers we’re working with ten to fifty meters, depending on the canvas size and pixel to meter ratio you are using. Continue reading Simulating Multiple Sources of Gravity in Box2D