I'll need to learn more math to understand all of what you did. :)
I saw that the angle routine was returning values 0-90. 90*4=360. 4 was the number of bad angles. This gave me a lead on the problem.
Upon removing the abs() from x and y differences my angle calculating routine returned 0-360 degrees
Now there was a glitch on only one angle, when it went from 180 to -180
I fixed it by checking if there were both negative and positive angles on the same frame. If so then remove 360 degrees from the positive slopes.
Code: Select all
dim as integer k,k1,k2,k3,k4
if slope1>0 then k+=1:k1=1
if slope2>0 then k+=1:k2=1
if slope3>0 then k+=1:k3=1
if slope4>0 then k+=1:k4=1
if k>0 and k<4 and plight.x<(box1.p2.x+box1.p3.x)/2 then
if k1=1 then slope1-=360
if k2=1 then slope2-=360
if k3=1 then slope3-=360
if k4=1 then slope4-=360
Sorry, if this is gibberish. I'm not so good at explaining myself.