I am making a 2D shooting game in Java, I need to be able to work out the maximum distance a circle could travel forwards (Only on the Y-axis) and get the distance as a float value, I have looked everywhere and can only find the closest distance to the line, but I only want the forward distance. This image is an example of how I am trying to get it to work, the line is a wall and the circles are bullets. If someone could give me a simple Java function that would be brilliant. I need it to take into account the whole circumference of the circle, so even if it slightly clips the wall with the edge, I need that distance. If the line is above the circle I want it to return a negative value, if the line is below I want a positive value, and if they would not collide, return POSITIVE_INFITITY.
I have tried many different functions I have found online but none seem to suit my purpose of just using the Y axis distance.

Most of the java.awt.geom framework contains helpful math functions.
The Line2D class has the Line2D#ptLineDist method, for calculating this distance, without the radius.
For that, I imagine you're calculating a different angle for the bullet.
This is at least a resource, for that solution.
Output