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:
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, ...