SCAR Code:
function FindDoor(var X, Y: Integer): Boolean;
var
X1, Y1, X2, Y2, I, Dots, R, G, B: Integer;
SkipCoords: TPointArray;
TempBMP, TheColor: Integer;
begin
repeat
TempBMP := BitmapFromString(5, 5, '');
if FindColorSkipCoordsTolerance(X1, Y1, 255, 569, 8, 715, 160, 25, SkipCoords) then
begin
CopyClientToBitmap(TempBMP, X1 - 2, Y1 - 2, X1 + 2, Y1 + 2);
TheColor := FastGetPixel(TempBMP, 2, 2);
ColorToRGB(TheColor, R, G, B);
if (G > 1) or (B > 1) then
begin
SetArrayLength(SkipCoords, I + 1);
SkipCoords[I].X := X1;
SkipCoords[I].Y := Y1;
I := I + 1;
end else
begin
for X2 := 0 to 4 do
begin
for Y2 := 0 to 4 do
begin
if TheColor = FastGetPixel(TempBMP, X2, Y2) then
begin
Dots := Dots + 1;
end;
end;
end;
end;
if Dots > 2 then
begin
X := X1;
Y := Y1;
Result := true;
FreeBitmap(TempBMP);
Exit;
end else
begin
SetArrayLength(SkipCoords, I + 1);
SkipCoords[I].X := X1;
SkipCoords[I].Y := Y1;
I := I + 1;
Dots := 0;
end;
end else
begin
Break;
end;
until (false);
FreeBitmap(TempBMP);
end;
SCAR Code:
function FindDoorMulti(var Coords: TPointArray; NumberOfDoors: Integer): Boolean;
var
X1, Y1, X2, Y2, I, Dots, R, G, B, N: Integer;
SkipCoords: TBoxArray;
TempBMP, TheColor: Integer;
begin
SetArrayLength(Coords, NumberOfDoors + 1);
TempBMP := BitmapFromString(5, 5, '');
repeat
if FindColorSkipBoxArrayTolerance(X1, Y1, 255, 569, 8, 715, 160, 25, SkipCoords) then
begin
CopyClientToBitmap(TempBMP, X1 - 2, Y1 - 2, X1 + 2, Y1 + 2);
TheColor := FastGetPixel(TempBMP, 2, 2);
ColorToRGB(TheColor, R, G, B);
if (G > 1) or (B > 1) then
begin
SetArrayLength(SkipCoords, I + 1);
SkipCoords[I].X1 := X1;
SkipCoords[I].Y1 := Y1;
SkipCoords[I].X2 := X1;
SkipCoords[I].Y2 := Y1;
I := I + 1;
end else
begin
for X2 := 0 to 4 do
begin
for Y2 := 0 to 4 do
begin
if TheColor = FastGetPixel(TempBMP, X2, Y2) then
begin
Dots := Dots + 1;
end;
end;
end;
end;
if Dots > 2 then
begin
Coords[N].X := X1;
Coords[N].Y := Y1;
N := N + 1;
SetArrayLength(SkipCoords, I + 1);
SkipCoords[I].X1 := X1 - 4;
SkipCoords[I].Y1 := Y1 - 4;
SkipCoords[I].X2 := X1 + 4;
SkipCoords[I].Y2 := Y1 + 4;
I := I + 1;
if N >= NumberOfDoors then
begin
Result := true;
FreeBitmap(TempBMP);
Exit;
end;
end else
begin
SetArrayLength(SkipCoords, I + 1);
SkipCoords[I].X1 := X1;
SkipCoords[I].Y1 := Y1;
SkipCoords[I].X2 := X1;
SkipCoords[I].Y2 := Y1;
I := I + 1;
Dots := 0;
end;
end else
begin
Break;
end;
until (false);
FreeBitmap(TempBMP);
end;