O'Reilly logo

jMonkeyEngine 3.0 Cookbook by Rickard Edén

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

Handling multiple gravity sources

Some games require handling gravity from multiple variable sources. In this recipe, we'll handle this and create a simple miniature solar system to demonstrate it using ThrusterControl from the Building a rocket engine recipe. To (greatly) simplify the relation between the planets, they won't affect each other with their gravity, but only the ship. It will also be made in a 2D-asteroids-like fashion, although the gravity would still apply for a 3D game.

We'll add some basic controls to rotate the ship to the left and right, and you can use the thruster to make the ship move forward.

How to do it...

Apart from ThrusterControl, we'll create two more small classes and an application class that joins everything together. ...

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