Ohk!
Tried your code out rain... and it is peculiar!
Is the naming of x1, y1, etc. important?
I named as:
/\
going clockwise, up, then down...
2
1 3
I also did (since there are multiple trees):
for i = 1 to trees
crosspoduct = ((x(1, i) - px) * (y(2, i) - py)) - ((x(2, i) - px) * (y(1, i) - py))
if sig(crossproduct) < 0 then
crosspoduct = ((x(2, i) - px) * (y(3, i) - py)) - ((x(3, i) - px) * (y(2, i) - py))
if sig(crossproduct) < 0 then
crosspoduct = ((x(3, i) - px) * (y(1, i) - py)) - ((x(1, i) - px) * (y(3, i) - py))
if sig(crossproduct) < 0 then
rem collision detected
fi
fi
fi
next
As I believe you cant achieve all tree collisions without x(n, i) etc.
Have I done this wrong?
I said (when a collisions was detected) to fill the screen with 0,0, 640,512 rectangle... it works... just not in the areas of the triangles.
Thanks!