hedgewars/uLand.pas
changeset 7556 4617e8ec0507
parent 7483 d479b98d38f7
child 7561 5f0b1829b16f
equal deleted inserted replaced
7554:e50b266ed85a 7556:4617e8ec0507
   125         until yd < 0;
   125         until yd < 0;
   126     end;
   126     end;
   127     SDL_FreeSurface(tmpsurf);
   127     SDL_FreeSurface(tmpsurf);
   128 end;
   128 end;
   129 
   129 
   130 procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr);
   130 procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray);
   131 var i: LongInt;
   131 var i: LongInt;
   132 begin
   132 begin
   133 with Template do
   133 with Template do
   134     begin
   134     begin
   135     pa.Count:= BasePointsCount;
   135     pa.Count:= BasePointsCount;
   146             begin
   146             begin
   147             for i:= 0 to pred(BasePointsCount) do
   147             for i:= 0 to pred(BasePointsCount) do
   148                if pa.ar[i].x <> NTPX then
   148                if pa.ar[i].x <> NTPX then
   149                    pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x;
   149                    pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x;
   150             for i:= 0 to pred(FillPointsCount) do
   150             for i:= 0 to pred(FillPointsCount) do
   151                 FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x;
   151                 fps^[i].x:= LAND_WIDTH - 1 - fps^[i].x;
   152             end;
   152             end;
   153 
   153 
   154 (*  Experiment in making this option more useful
   154 (*  Experiment in making this option more useful
   155      if ((not isNegative) and (cTemplateFilter = 4)) or
   155      if ((not isNegative) and (cTemplateFilter = 4)) or
   156         (canFlip and (getrandom(2) = 0)) then
   156         (canFlip and (getrandom(2) = 0)) then
   179             if pa.ar[i].y < 0 then
   179             if pa.ar[i].y < 0 then
   180                 pa.ar[i].y:= 0;
   180                 pa.ar[i].y:= 0;
   181             end;
   181             end;
   182         for i:= 0 to pred(FillPointsCount) do
   182         for i:= 0 to pred(FillPointsCount) do
   183             begin
   183             begin
   184             dec(FillPoints^[i].y, 100);
   184             dec(fps^[i].y, 100);
   185             if FillPoints^[i].y < 0 then
   185             if fps^[i].y < 0 then
   186                 FillPoints^[i].y:= 0;
   186                 fps^[i].y:= 0;
   187             end;
   187             end;
   188         end;
   188         end;
   189 
   189 
   190     if (canFlip and (getrandom(2) = 0)) then
   190     if (canFlip and (getrandom(2) = 0)) then
   191         begin
   191         begin
   192         for i:= 0 to pred(BasePointsCount) do
   192         for i:= 0 to pred(BasePointsCount) do
   193             pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y;
   193             pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y;
   194         for i:= 0 to pred(FillPointsCount) do
   194         for i:= 0 to pred(FillPointsCount) do
   195             FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y;
   195             fps^[i].y:= LAND_HEIGHT - 1 - fps^[i].y;
   196         end;
   196         end;
   197     end
   197     end
   198 end;
   198 end;
   199 
   199 
   200 
   200 
   201 procedure GenBlank(var Template: TEdgeTemplate);
   201 procedure GenBlank(var Template: TEdgeTemplate);
   202 var pa: TPixAr;
   202 var pa: TPixAr;
   203     i: Longword;
   203     i: Longword;
   204     y, x: Longword;
   204     y, x: Longword;
   205 begin
   205 	fps: TPointArray;
       
   206 begin
       
   207 	fps:=Template.FillPoints^;
   206     ResizeLand(Template.TemplateWidth, Template.TemplateHeight);
   208     ResizeLand(Template.TemplateWidth, Template.TemplateHeight);
   207     for y:= 0 to LAND_HEIGHT - 1 do
   209     for y:= 0 to LAND_HEIGHT - 1 do
   208         for x:= 0 to LAND_WIDTH - 1 do
   210         for x:= 0 to LAND_WIDTH - 1 do
   209             Land[y, x]:= lfBasic;
   211             Land[y, x]:= lfBasic;
   210     {$HINTS OFF}
   212     {$HINTS OFF}
   211     SetPoints(Template, pa);
   213     SetPoints(Template, pa, @fps);
   212     {$HINTS ON}
   214     {$HINTS ON}
   213     for i:= 1 to Template.BezierizeCount do
   215     for i:= 1 to Template.BezierizeCount do
   214         begin
   216         begin
   215         BezierizeEdge(pa, _0_5);
   217         BezierizeEdge(pa, _0_5);
   216         RandomizePoints(pa);
   218         RandomizePoints(pa);
   223 
   225 
   224     DrawEdge(pa, 0);
   226     DrawEdge(pa, 0);
   225 
   227 
   226     with Template do
   228     with Template do
   227         for i:= 0 to pred(FillPointsCount) do
   229         for i:= 0 to pred(FillPointsCount) do
   228             with FillPoints^[i] do
   230             with fps[i] do
   229                 FillLand(x, y);
   231                 FillLand(x, y);
   230 
   232 
   231     DrawEdge(pa, lfBasic);
   233     DrawEdge(pa, lfBasic);
   232 
   234 
   233     MaxHedgehogs:= Template.MaxHedgehogs;
   235     MaxHedgehogs:= Template.MaxHedgehogs;