hedgewars/uLandGenTemplateBased.pas
changeset 10472 8d04cebedb16
parent 10387 cb17b79844b5
child 10477 b219c5a2317f
equal deleted inserted replaced
10471:d968b1ac130c 10472:8d04cebedb16
     7 procedure DivideEdges(fillPointsCount: LongWord; var pa: TPixAr);
     7 procedure DivideEdges(fillPointsCount: LongWord; var pa: TPixAr);
     8 
     8 
     9 implementation
     9 implementation
    10 uses uVariables, uConsts, uFloat, uLandUtils, uRandom, SDLh, math;
    10 uses uVariables, uConsts, uFloat, uLandUtils, uRandom, SDLh, math;
    11 
    11 
       
    12 var minDistance: LongInt; // different details size
    12 
    13 
    13 procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray);
    14 procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr; fps: PPointArray);
    14 var i: LongInt;
    15 var i: LongInt;
    15 begin
    16 begin
    16     with Template do
    17     with Template do
    95     BezierizeEdge(pa, _0_1);
    96     BezierizeEdge(pa, _0_1);
    96 end;
    97 end;
    97 
    98 
    98 procedure FindPoint(si: LongInt; fillPointsCount: LongWord; var newPoint: TPoint; var pa: TPixAr);
    99 procedure FindPoint(si: LongInt; fillPointsCount: LongWord; var newPoint: TPoint; var pa: TPixAr);
    99 const mapBorderMargin = 40;
   100 const mapBorderMargin = 40;
   100     minDistance = 32; // adjust/parametrize this for different details size
       
   101 var p1, p2, p4, fp, mp: TPoint;
   101 var p1, p2, p4, fp, mp: TPoint;
   102     i, t1, t2, iy, ix, aqpb: LongInt;
   102     i, t1, t2, iy, ix, aqpb: LongInt;
   103     a, b, p, q: LongInt;
   103     a, b, p, q: LongInt;
   104     dab, d, distL, distR: LongInt;
   104     dab, d, distL, distR: LongInt;
   105 begin
   105 begin
   334     fps:=Template.FillPoints^;
   334     fps:=Template.FillPoints^;
   335     ResizeLand(Template.TemplateWidth, Template.TemplateHeight);
   335     ResizeLand(Template.TemplateWidth, Template.TemplateHeight);
   336     for y:= 0 to LAND_HEIGHT - 1 do
   336     for y:= 0 to LAND_HEIGHT - 1 do
   337         for x:= 0 to LAND_WIDTH - 1 do
   337         for x:= 0 to LAND_WIDTH - 1 do
   338             Land[y, x]:= lfBasic;
   338             Land[y, x]:= lfBasic;
   339             
   339     
       
   340     minDistance:= max(cFeatureSize,12);
   340     MaxHedgehogs:= Template.MaxHedgehogs;
   341     MaxHedgehogs:= Template.MaxHedgehogs;
   341     hasGirders:= Template.hasGirders;
   342     hasGirders:= Template.hasGirders;
   342     playHeight:= Template.TemplateHeight;
   343     playHeight:= Template.TemplateHeight;
   343     playWidth:= Template.TemplateWidth;
   344     playWidth:= Template.TemplateWidth;
   344     leftX:= (LAND_WIDTH - playWidth) div 2;
   345     leftX:= (LAND_WIDTH - playWidth) div 2;