A scenario of another ball passing through the bridge was found and this time the path was drawn from left to right. The following line of code only holds true if the bridge is drawn from left to right because it is programmed to always first compare ballX with xStart(x-cords on mouseDown ), then ballX with xEnd (x-cords on mouseUp).
Need to amend code to:
Calculate xRange between xStart and xEnd of line and Math.abs() it.
Add either xStart or xEnd whichever is smaller to xRange,
(In the case where path is drawn from left to right, xEnd <xStart ) Then compare the ballX first to xEnd, then later( xEnd+xRange).
A scenario of another ball passing through the bridge was found and this time the path was drawn from left to right. The following line of code only holds true if the bridge is drawn from left to right because it is programmed to always first compare ballX with xStart(x-cords on mouseDown ), then ballX with xEnd (x-cords on mouseUp).
Need to amend code to: