Have you ever wondered how do you detect that a object has hit another object? Well, some computational geometry functions should come in handy.

The black line is the line that we want to detect if something hits it. The end coordinates are (a.x, a.y) and (b.x, b.y).
The point (c.x, c.y) is the point that will cross the line (a, b). If we compute the surface of the area going from a->b->c we should get an area with a different sign in comparison with the triangle (a,b,d).
So, we simply compute the surface every time the point c moves towards the line.
/*
Returns the area sign of the triangle formed by the vectors ab, bc, ca
Area Sign Vertices Walk Point c Location
------------------------------------------------------
1 Clockwise Right of ab
-1 Clockwise Left of ab
0 Clockwise On ab
1 Counter-Clockwise Left of ab
-1 Counter-Clockwise Right of ab
0 Counter-Clockwise On ab
*/
public function areaSign(c:Point):int {
var a:Point = this.getBegin();
var b:Point = this.getEnd();
var area2:Number; // This is twice the area of the triangle. IE: Parallelogram
area2 = ( b.x - a.x ) * ( c.y - a.y ) -
( c.x - a.x ) * ( b.y - a.y );
/* The area should be an integer. */
if ( area2 > 0.5 ) return 1;
else if ( area2 < -0.5 ) return -1;
else return 1;
}
Here's an example using the code above. Each player bar is a rectangle with 4 lines like the one in the picture above.
MeasureIt