It looks like a game in 2D. Now, taking all the world coordinates:
Target Position: {xt, yt} Target Velocity: {vxt, vyt} Ship Position: {xs, ys}
Now, let's say you hit a bullet in the direction of {bx, by} , this is a direction vector or a unit vector. The bullet has an sb speed. Therefore, in time t' spatial coordinates of the bullet and the target will be:
Target New Position: {xt + vxt*t', yt + vyt*t'} Bullet New Position: {xs + bx*sb*t', ys + by*sb*t'} ( bullet starts from ship)
Since at this time both the bullet and the target should be in the same place, then we can say that the bullet hit the target. Therefore, we can replace the new target position with the new location of the bullet (after time t '):
xt + vxt*t' = xs + bx*sb*t' yt + vyt*t' = ys + by*sb*t'
As I said earlier, bx and by are directivity vectors, so bx^2 + by^2 = 1
(xt + vxt*t' - xs)/(sb*t') = bx (yt + vyt*t' - ys)/(sb*t') = by bx^2 + by^2 = 1
Therefore, after squaring and adding them, you will receive:
(yt + vyt*t' - ys)^2 + (xt + vxt*t' - xs)^2 = (sb*t')^2
This is a quadratic equation with one variable: t' solve it, and then you can find bx and by .