# How to draw a line based on an angle with a defined size?

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:

draw_line(x,y,mouse_x,mouse_y);


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.

seno=dsin(point_direction(x,y,mouse_x,mouse_y));

draw_line(x,y,x+(500*cose),y+(-500*seno));