O'Reilly logo

Android Game Recipes: A Problem-Solution Approach by J. F. DiMarzio

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

Chapter     14

Firing Weapons

Many games require the player to fire or throw weapons at obstacles or enemies. If you have ever tried to fire weapons, you have likely encountered problems in getting your projectiles to leave your character in a predictable manner, and travel along a set path to a target.

Weapons can come in many shapes, sizes, and functions. Bullets, in many gaming situations, travel in straight lines, as do missiles, lasers, and most other propelled weapons. Thrown weapons, such as rocks, grenades, and even arrows to an extent, follow trajectories that are more parabolic. Regardless of the image or animation that you choose to use for the weapon, the math for getting it from point A to point B will be mostly the same.

This chapter ...

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