Everything is in .12 fixed point to work with the Lerp trig functions. I have a "gun" that rotates and bullets that fire with a velocity found with the negative cosLerp for x and sinLerp for y. I'm testing different bullet speeds with varied multipliers.
At the same time, I record the angle of fire (from the gun's angle) in the bullet's structure and begin to use a similar to cohen-sutherland type algorithm to check for simple rejections...
At certain points, however, I begin to check if line segments intersect with borders of the target like this for example:
Code: Select all
y = ymax; // bottom border of target...
x = x0 + divf32(y - y0, tanLerp(angle)); // find intersect x value where y = ymax...
if(x < xmax && x > xmin){//etc