SRL Archive - OSR Help

Finding static colors


xdarkshadowx

2013-01-03 16:52:58

Trying to make a simba program that will check the colors on the screen every 2 seconds, and weed out colors that have changed as to leave you only with the points that are 'static' so you can use them as base point for location ect ect. But I'm getting out of bounds error on line 12. Little help please? :)



program new;

{$i srl/srl.simba}
var
colourArray: TPointArray;
width, height,w,h,i: integer;
procedure checkForPoints;
begin
for w := 0 to width do
for h := 0 to Height do
begin
if((colourArray[w + (h*width)].x = getColor(w,h)) and (not colourArray[w + (h*width)].y = 0)) then
begin
writeln(inttostr(w) + ',' + inttostr(h));
end
else
begin
colourArray[w + (h*width)].y := 0;
end;
end;
wait(2000);
end;
procedure writePoints;
begin
for i := 0 to length(colourArray)-1 do
begin
writeln(inttostr(colourArray[i].x) + ' ' + inttostr(colourArray[i].y));
end;
end;

begin
addonTerminate('writePoints');



repeat


GetClientDimensions(width,Height);
//////////////////////////
setLength(colourArray, width*height + 1);
for w := 0 to width do
for h := 0 to Height-1 do
begin
colourArray[w + (h*width)].x := getColor(w,h);
colourArray[w + (h*width)].y := 1;
end;
///////////////////////////
for i := 0 to 10 do
begin
checkForPoints;
end;






until(true);
end.

Brandon

2013-01-03 17:41:29

Try Iterating from 1 to High instead? Your code needs better formatting because it's complicated to read atm..