Procedure Find_Ant, Control, Monitor

Zpět
procedure TAnt_Hill.Find_Ant(x,y : integer);
var i,px,py:integer;
    found : boolean;
begin
 found:=false;
 i:=0;
 while (i<=curr_num_ants) and (found=false) do // bez rovnosti
   begin
    px:=round(Data_Ants[i].xx);
    py:=round(Data_Ants[i].yy);
    if (x>px-30) and (x<=px+30) and (y>py-30) and (y<=py+30)then // bez rovnosti
      begin
       found:=true;
       if Data_Ants[i].move_ant=1 then Data_Ants[i].move_ant:=0
             else Data_Ants[i].move_ant:=1;
      end;
    inc(i);
   end;
end;

procedure TAnt_Hill.Control_Ant(x,y : integer);
var i,px,py:integer;
    found : boolean;
begin
 found:=false;
 i:=0;
 while (i<=curr_num_ants) and (found=false) do // bez rovnosti
   begin
    px:=round(Data_Ants[i].xx);
    py:=round(Data_Ants[i].yy);
    if (x>px-30) and (x<=px+30) and (y>py-30) and (y<=py+30)then // bez rovnosti
      begin
       found:=true;
       if (control>=0) then Data_Ants[control].move_ant:=0;
       Data_Ants[i].move_ant:=2;
       control := i;
      end;
    inc(i);
   end;
   if (found=false)  then begin
       if (control>=0) then Data_Ants[control].move_ant:=0;
       control := -1;
     end;
end;

procedure TAnt_Hill.Monitor_Ant(x,y : integer);
var i,px,py:integer;
    found : boolean;
begin
 found:=false;
 i:=0;
 while (i<=curr_num_ants) and (found=false) do   // bez rovnosti
   begin
    px:=round(Data_Ants[i].xx);
    py:=round(Data_Ants[i].yy);
    if (x>px-30) and (x<=px+30) and (y>py-30) and (y<=py+30)then  // bez rovnosti
      begin
       found:=true;
       if (control>=0) then Data_Ants[control].move_ant:=0;
       Data_Ants[i].move_ant:=5;
       control := i;
      end;
    inc(i);
   end;
   if (found=false)  then begin
       if (control>=0) then Data_Ants[control].move_ant:=0;
       control := -1;
     end;
end;