Computing Collision Point
As seen in the diagram, when the user fires the projectile, the projectile travels along a straight line originating at the center of the weapon and at the weapon's angle relative to the vertical axis. Also, the moving target is traveling along a straight horizontal line. A collision occurs if both objects are at the intersection of the two lines at the same time. A strategy for determining this is to have each class object compute the time it takes to get to the point of intersection and then compare those times. But we take a slightly different approach by having the projectile compute its time and pass the time onto the moving target. In turn, the moving target when given the "hit" time can declare if it will be hit (see the descriptions of the two objects projectile and moving target).