for each line (represented by ax+by+c = 0) and each object(which moved from x0,y0 to x1 y1) you have to check if the result of this product is negetive (a*x0+b*y0+c)*(a*x1+b*y1+c)
. negetive value means there is a collision somewhere(it may be after the both end of line) and the possitive value means there are no collisions. if there realy was a collision then you have to calculate collision point using these formulas and check if that's somewhere between two ends of your line.
we want to calculate the collision point of these 2 lines :
ax+bx+c = 0
(x1-x0)x+(y1-y0)y - (x1-x0)x0+(y1-y0)y0 = 0
so we set these 3 parameters for comuting ease:
a' = x1 - x0
b' = y1 - y0
c' = -(a' * x0 + b' * y0)
and now our problem is :
ax +by +c = 0;
a'x+b'y+c' = 0;
and then you can have x',y'(collision coordinates)
x' = -(c/b + c') /(a' + b'/b*a)
y' = -(c/a + c') /(b' + a'/a*b)
after that to check if it's inside the line fragment you have to check if (x0-x')*(x1-x')+(y0-y')*(y1-y')
is a negetive value, if yes you have a real collision if not the object is past from sides of your line.