hmm...the code seems to be returning true for me most of the time, so I get flickering energy discharges at the target as it thinks the circle and pie are intersecting lots...
I am setting up the circle and pie like this:
Code:
BeamHasHitPlayer := False;
if Assigned(FPlayer) then
begin
Circle.c := G2Vec2(FPlayer.x,FPlayer.y);
Circle.r := FPlayer.Width * 0.4;
Pie.c := G2Vec2(aSentry.x,aSentry.y);
Pie.r := aSentry.BeamRange;
Pie.AngStart := aSentry.Angle - aSentry.BeamWidth/2;
Pie.AngEnd := aSentry.Angle + aSentry.BeamWidth/2;
BeamHasHitPlayer := CircleVsPieIntersect(Circle,Pie);
end;
Any ideas?
If it helps, the beam width is 50 degrees wide, and the screen coordinate system being used is this (if it makes a difference?):
Code:
0,0
+---------------------- +X
|
|
|
|
|
|
|
+Y
cheers,
Paul
Bookmarks