O'Reilly logo

Sams Teach Yourself Android Game Programming in 24 Hours by Jonathan S. Harbour

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

Hour 22. Using Linear Velocity for Realistic Movement

What You’ll Learn in This Hour

• How to calculate velocity from any direction

• How to move based on rotation angle

• How to calculate the angle to a target

• How to make final changes to the Android game engine

This hour expands on the concepts learned in the last two hours—dealing with transforms and collision detection—to move objects in any direction based on velocity of an angle. We will derive the math calculations needed to move a sprite in any desired direction based on its rotation angle (from a top-down perspective). Moving a sprite at a desired angle is a very important need in most games, so you will no doubt use this technique extensively in your own projects. The next related ...

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