hedgewars/uLandGenPerlin.pas
changeset 10479 31afb7cdff69
parent 10391 ce3ccc45d790
child 10491 c92955fa8b67
equal deleted inserted replaced
10478:12662c21e0e9 10479:31afb7cdff69
     8 implementation
     8 implementation
     9 uses uVariables
     9 uses uVariables
    10     , uConsts
    10     , uConsts
    11     , uRandom
    11     , uRandom
    12     , uLandOutline // FillLand
    12     , uLandOutline // FillLand
       
    13     , uUtils
    13     ;
    14     ;
    14 
    15 
    15 var p: array[0..511] of LongInt;
    16 var p: array[0..511] of LongInt;
    16 
    17 
    17 const fadear: array[byte] of LongInt = 
    18 const fadear: array[byte] of LongInt = 
   118 
   119 
   119     for i:= 0 to 255 do
   120     for i:= 0 to 255 do
   120         p[256 + i]:= p[i];
   121         p[256 + i]:= p[i];
   121 end;
   122 end;
   122 
   123 
   123 const detail = 150000;
   124 const width = 4096;
   124     width = 4096;
   125       height = 2048;
   125     height = 2048;
   126       minY = 500;
   126     minY = 500;
       
   127 
   127 
   128     //bottomPlateHeight = 90;
   128     //bottomPlateHeight = 90;
   129     //bottomPlateMargin = 1200;
   129     //bottomPlateMargin = 1200;
   130     margin = 200;
   130     margin = 200;
   131 
   131 
   132 procedure GenPerlin;
   132 procedure GenPerlin;
   133 var y, x, {dy, }di, dj, df, r, param1, param2: LongInt;
   133 var y, x, {dy, }di, dj, df, r, param1, param2, rCutoff, detail: LongInt;
   134 begin
   134 begin
   135     param1:= cTemplateFilter div 3;
   135     param1:= cTemplateFilter div 3;
   136     param2:= cTemplateFilter mod 3;
   136     param2:= cTemplateFilter mod 3;
       
   137     rCutoff:= min(max(cFeatureSize*4,15),85);
       
   138     detail:= cFeatureSize*16000+50000;
   137 
   139 
   138     df:= detail * (6 - param2 * 2);
   140     df:= detail * (6 - param2 * 2);
   139 
   141 
   140     inoise_setup();
   142     inoise_setup();
   141 
   143 
   167                 if x + bottomPlateMargin + bottomPlateHeight > width then
   169                 if x + bottomPlateMargin + bottomPlateHeight > width then
   168                     r:= r - (x - width + bottomPlateMargin + bottomPlateHeight);
   170                     r:= r - (x - width + bottomPlateMargin + bottomPlateHeight);
   169             end;
   171             end;
   170             }
   172             }
   171 
   173 
   172             if r < 50 then Land[y, x]:= 0 else Land[y, x]:= lfObjMask;
   174             if r < rCutoff then Land[y, x]:= 0 else Land[y, x]:= lfObjMask;
   173 
   175 
   174         end;
   176         end;
   175     end;
   177     end;
   176 
   178 
   177     if param1 = 0 then
   179     if param1 = 0 then