hedgewars/uLandGenPerlin.pas
changeset 10187 0d506346c1f0
parent 10186 3fa109a1ae95
child 10188 e8f2dbabd01b
equal deleted inserted replaced
10186:3fa109a1ae95 10187:0d506346c1f0
    94 
    94 
    95 const detail = 120000*3;
    95 const detail = 120000*3;
    96     field = 3;
    96     field = 3;
    97     width = 4096;
    97     width = 4096;
    98     height = 2048;
    98     height = 2048;
       
    99     bottomPlateHeight = 90;
       
   100     bottomPlateMargin = 1200;
       
   101     plateFactor = 1;
    99 
   102 
   100 procedure GenPerlin;
   103 procedure GenPerlin;
   101 var y, x, di, dj, r: LongInt;
   104 var y, x, dy, di, dj, r: LongInt;
   102 begin
   105 begin
   103     inoise_setup();
   106     inoise_setup();
   104 
   107 
   105     for y:= 1024 to pred(height) do
   108     for y:= 1024 to pred(height) do
   106     begin
   109     begin
   107         di:= detail * field * y div height;
   110         di:= detail * field * y div height;
   108         for x:= 0 to pred(width) do
   111         for x:= 0 to pred(width) do
   109         begin
   112         begin
   110             dj:= detail * field * x div width;
   113             dj:= detail * field * x div width;
   111             r:= (abs(inoise(di, dj))) shr 8 and $ff;
   114             r:= (abs(inoise(di, dj))) shr 8 and $ff;
   112             r:= r - max(0, abs(x - width div 2) - width * 55 div 128); // fade on edges
   115             //r:= r - max(0, abs(x - width div 2) - width * 55 div 128); // fade on edges
   113             //r:= r - max(0, - abs(x - width div 2) + width * 2 div 100); // split vertically in the middle
   116             //r:= r - max(0, - abs(x - width div 2) + width * 2 div 100); // split vertically in the middle
   114 
   117 
   115 
   118 
   116             //r:= r + (trunc(1000 - sqrt(sqr(x - (width div 2)) * 4 + sqr(y - height * 5 div 4) * 22))) div 600 * 20; // ellipse
   119             //r:= r + (trunc(1000 - sqrt(sqr(x - (width div 2)) * 4 + sqr(y - height * 5 div 4) * 22))) div 600 * 20; // ellipse
   117             r:= r + (trunc(2000 - (abs(x - (width div 2)) * 2 + abs(y - height * 5 div 4) * 4))) div 512 * 20; // manhattan length ellipse
   120             r:= r + (trunc(2000 - (abs(x - (width div 2)) * 2 + abs(y - height * 5 div 4) * 4))) div 26; // manhattan length ellipse
   118 
   121 
       
   122             if (y > height - bottomPlateHeight) and (x > bottomPlateMargin) and (x + bottomPlateMargin < width) then
       
   123             begin
       
   124                 dy:= (y - height + bottomPlateHeight) * plateFactor;
       
   125                 r:= r + dy;
       
   126 
       
   127                 if x < bottomPlateMargin + bottomPlateHeight then
       
   128                     r:= r + (x - bottomPlateMargin - bottomPlateHeight) * plateFactor
       
   129                 else
       
   130                 if x + bottomPlateMargin + bottomPlateHeight > width then
       
   131                     r:= r - (x - width + bottomPlateMargin + bottomPlateHeight) * plateFactor;
       
   132             end;
   119             if r < 0 then Land[y, x]:= 0 else Land[y, x]:= lfBasic;
   133             if r < 0 then Land[y, x]:= 0 else Land[y, x]:= lfBasic;
   120 
   134 
   121         end;
   135         end;
   122     end;
   136     end;
   123 
   137