procedure TAnt_Hill.Add_Wood(count_woods: byte )
procedure TAnt_hill.Add_Eggs(x,y : integer)
procedure TAnt_Hill.Add_Wood(count_woods: byte );
var i, pom,px,py:integer ;
begin
pom:=0;
i:=0;
while ((i<=curr_num_woods) and (pom<=count_woods)) do // bez rovnosti
begin
if Data_Wood[i].where=3 then
begin
repeat
randomize;
px := random(750)+20;
py := random(550)+20;
until ((px<(curr_pos_ant_hill_x-(curr_size_ant_hill div 2))) or (px>(curr_pos_ant_hill_x+(curr_size_ant_hill div 2)))) and
((py<(curr_pos_ant_hill_y-(curr_size_ant_hill div 2))) or (py>(curr_pos_ant_hill_y+(curr_size_ant_hill div 2)))) and
((px<=position_well_x) or (px>(position_well_x+32))) and
((py<=position_well_y) or (py>(position_well_y+32))) ;
Data_Wood[i].x:=px;
Data_Wood[i].y:=py;
Data_Wood[i].where:=2; // vetvicka je na plose
inc(pom);
end;
inc(i);
end;
curr_num_woods_really := curr_num_woods_really + count_woods ;
end;
procedure TAnt_hill.Add_Eggs(x,y : integer);
var i, pom,px,py:integer ;
added : boolean;
begin
i:=0;
added := false ;
while ((i<=curr_num_eggs) and (added=false)) do // bez rovnost
begin
if Data_Egg[i].where=3 then
begin
Data_Egg[i].x:=x;
Data_Egg[i].y:=y;
Data_Egg[i].where:=2; // vetvicka je na plose
added:=true;
end;
inc(i);
end;
if added=false then begin // neni misto pro nove vajicko zvetsime pole
inc(curr_num_eggs);
SetLength(Data_Egg,curr_num_eggs);
Data_Egg[curr_num_eggs-1].x:=x;
Data_Egg[curr_num_eggs-1].y:=y;
Data_Egg[curr_num_eggs-1].where:=2; // vetvicka je na plose
end;
end;
|