I'm creating a little game and i'm trying to calculate the final point to draw the bullet movement. I getting troubles trying to calculate the final point of the line having the bullet vector [-1,0 for left, 0,1 for the upper direction, etc] and the starting point of the rect and the range or line length.
Calculus :
Rect general equation --> (x,y) = Pi + v*t
x = Pi(x) + V(x)*t;
y = Pi(y)+ V(y)*t;
Isolating the t var:
t = x - Pi(x) / V(x);
t = y - Pi(y) / V(y);
Combining both equations :
x - Pi(x) / V(x) = y - Pi(y) / V(y);
And on the other side, the calculus of the line length.
[pf(x) - pi(x) ]^2 + [pf(y) - pi(y)]^2 = r^2
I'm doing it correctly ?? I'm very confused if i doing the right calculus or there is a shorter way to calculate the end point of the line.