I have a game where the player shoots a projectile based on the mouse direction when clicking, which travels 500 pixels.
I wish I could draw a line exactly where the projectile will be destroyed.
What I can do is draw a line from where the projectile is created to where the mouse is when it is clicked.
That is, the line may be longer or shorter than the path taken by the projectile.
The code is something like this:
Result in game:
Below an image explaining:
These blue dots would be the click of the mouse. That no matter where it went, the line drawn (green) would be the same (ending in pink x).
I know how to get the direction and how to calculate the distance, but I don't know how to implement it in line drawing.