I'm developing a 2d game in JS and stuck on a trigonometry problem.
Problem: Player shoots a target. The shot is blocked by an obstacle. The obstacle is between the player and the target. I need to figure out the coordinates of this obstacle.
I have 3 pieces of information:
- starting coordinate of shot (x1,y1)
- ending coordinate of shot (x2, y2)
- distance between the starting coordinate and the obstacle
How do I figure out the (x,y) of the obstacle in the way of the shot?
Bonus points: An efficient solution in Javascript.
Picture for reference.
