O'Reilly logo

The Essential Guide to Physics for Flash Games, Animation, and Simulations by Adrian Dobre, Dev Ramtal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Build a submarine

In Chapter 7 we had a simple but interesting example of a ball floating in water. It is actually quite easy to modify that example and turn it into an interactive submarine of a type that can be used in simple 2D games. Let's first quickly review the main physics involved.

Brief review of the physics

In the floating ball example, we identified three main forces that acted on the ball: gravity, upthrust, and drag, which are given respectively by the following formulas:

Image

Note that we have written the upthrust formula in vector form: the minus sign is because upthrust acts upward, opposing the gravity vector g. Just as a reminder, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required