masquerader
2006-10-03 18:42:17
so, i finally got around to figuring out why freddy's functions didnt work, and it turned out to be because i didnt have setupsrl; in there :duh:
i got that working and quick rewrote the compass function i had in the other topic
seeing as its half the size and a lot quicker now, i might add it to srl
would you use it, or does makecompass do it for you?
i got that working and quick rewrote the compass function i had in the other topic
seeing as its half the size and a lot quicker now, i might add it to srl
would you use it, or does makecompass do it for you?
program New;
{.include srl/srl.scar}
function findsrlcompassangle:integer;
//returns degrees counter-clockwise compass is rotated
//by masquerader
var
tics:array[0..2] of tpoint;
skip:tboxarray;
x,y,i,j,found,south:integer;
begin
setarraylength(skip,1);
skip[0]:=cbox2(559,11,573, 28);
for i:=0 to 2 do
begin
if(findcolorskipboxarray(tics[i].x,tics[i].y,920735,547, 2,584, 39,skip))then
begin
found:=found+1;
j:=getarraylength(skip);
setarraylength(skip,j+1);
skip[j]:=cbox2(tics[i].x-4,tics[i].y-4,tics[i].x+4,tics[i].y+4);
end;
end;
if(found<>3)then
writeln('something went wrong, couldnt find the 3 compass tics');
if(distance(tics[0].x,tics[0].y,tics[1].x,tics[1].y)>22)then
south:=2
else
if(distance(tics[0].x,tics[0].y,tics[2].x,tics[2].y)>22)then
south:=1
else
south:=0;
x:=tics[south].x-566;
y:=tics[south].y-21;
result:=round(degrees(arctan2(y,x)))-90;
if(((x>0)and(y>0))or((x<0)and(y<0)))then
result:=result*-1;
if(((x>0)and(y<0))or((x<0)and(y>0)))then
result:=result-90;
result:=trunc(fixd(result));
end;
begin
setupsrl;
writeln(inttostr(findsrlcompassangle));
end.