hedgewars/uLand.pas
changeset 27 c374fe590272
parent 24 79c411363184
child 35 9367f246fb5f
equal deleted inserted replaced
26:e32fa14529f8 27:c374fe590272
   346           repeat
   346           repeat
   347           inc(y, 2);
   347           inc(y, 2);
   348           inc(t, 2)
   348           inc(t, 2)
   349           until (y > 1023) or (CountNonZeroz(x, y) <> 0);
   349           until (y > 1023) or (CountNonZeroz(x, y) <> 0);
   350           if (t > 22) and (y < 1023) then AddHHPoint(x, y - 12);
   350           if (t > 22) and (y < 1023) then AddHHPoint(x, y - 12);
   351           inc(y, 100)
   351           inc(y, 80)
   352           end;
   352           end;
   353     inc(x, 120)
   353     inc(x, 100)
   354     end;
   354     end;
   355 
   355 
   356 if HHPoints.Last < cMaxHHs then
   356 if HHPoints.Last < cMaxHHs then
   357    begin
   357    begin
   358    AddHHPoint(300, 800);
   358    AddHHPoint(300, 800);
   369    AddHHPoint(1400, 800);
   369    AddHHPoint(1400, 800);
   370    end;
   370    end;
   371 end;
   371 end;
   372 
   372 
   373 procedure PointWave(var Template: TEdgeTemplate; var pa: TPixAr);
   373 procedure PointWave(var Template: TEdgeTemplate; var pa: TPixAr);
   374 const MAXPASSES = 16;
   374 const MAXPASSES = 32;
   375 var ar: array[1..MAXPASSES, 0..5] of real;
   375 var ar: array[0..MAXPASSES, 0..5] of real;
   376     i, k: integer;
   376     i, k: integer;
   377     rx, ry, oy: real;
   377     rx, ry, oy: real;
   378     PassesNum: Longword;
   378     PassesNum: Longword;
   379 begin
   379 begin
   380 with Template do
   380 with Template do
   381      begin
   381      begin
   382      PassesNum:= PassMin + getrandom(PassDelta);
   382      PassesNum:= PassMin + getrandom(PassDelta);
   383      TryDo(PassesNum < MAXPASSES, 'Passes number too big', true);
   383      TryDo(PassesNum < MAXPASSES, 'Passes number too big', true);
       
   384      ar[0, 1]:= WaveFreqMin;
       
   385      ar[0, 4]:= WaveFreqMin;
   384      for i:= 1 to PassesNum do  // initialize random parameters
   386      for i:= 1 to PassesNum do  // initialize random parameters
   385          begin
   387          begin
   386          ar[i, 0]:= WaveAmplMin + getrandom * WaveAmplDelta;
   388          ar[i, 0]:= WaveAmplMin + getrandom * WaveAmplDelta;
   387          ar[i, 1]:= WaveFreqMin + getrandom * WaveFreqDelta;
   389          ar[i, 1]:= ar[i - 1, 1] + (getrandom * 0.7 + 0.3) * WaveFreqDelta;
   388          ar[i, 2]:= getrandom * pi * 2;
   390          ar[i, 2]:= getrandom * pi * 2;
   389          ar[i, 3]:= WaveAmplMin + getrandom * WaveAmplDelta;
   391          ar[i, 3]:= WaveAmplMin + getrandom * WaveAmplDelta;
   390          ar[i, 4]:= WaveFreqMin + getrandom * WaveFreqDelta;
   392          ar[i, 4]:= ar[i - 1, 4] + (getrandom * 0.7 + 0.3) * WaveFreqDelta;
   391          ar[i, 5]:= getrandom * pi * 2;
   393          ar[i, 5]:= getrandom * pi * 2;
   392          end;
   394          end;
   393      end;
   395      end;
   394 
   396 
   395 for k:= 0 to Pred(pa.Count) do  // apply transformation
   397 for k:= 0 to Pred(pa.Count) do  // apply transformation
   411 var pa: TPixAr;
   413 var pa: TPixAr;
   412     i: Longword;
   414     i: Longword;
   413 begin
   415 begin
   414 with Template do
   416 with Template do
   415      begin
   417      begin
       
   418      if canMirror then
       
   419         if getrandom(16) < 8 then
       
   420            begin
       
   421            for i:= 0 to pred(BasePointsCount) do
       
   422                BasePoints^[i].x:= 2047 - BasePoints^[i].x;
       
   423            for i:= 0 to pred(FillPointsCount) do
       
   424                FillPoints^[i].x:= 2047 - FillPoints^[i].x;
       
   425            end;
       
   426 
       
   427      if canFlip then
       
   428         if getrandom(16) < 8 then
       
   429            begin
       
   430            for i:= 0 to pred(BasePointsCount) do
       
   431                BasePoints^[i].y:= 1023 - BasePoints^[i].y;
       
   432            for i:= 0 to pred(FillPointsCount) do
       
   433                FillPoints^[i].y:= 1023 - FillPoints^[i].y;
       
   434            end;
       
   435 
   416      pa.Count:= BasePointsCount;
   436      pa.Count:= BasePointsCount;
   417      for i:= 0 to pred(pa.Count) do
   437      for i:= 0 to pred(pa.Count) do
   418          pa.ar[i]:= BasePoints^[i];
   438          pa.ar[i]:= BasePoints^[i];
   419 
   439 
   420      for i:= 1 to BezPassCnt do
   440      for i:= 1 to BezPassCnt do
   441 AddProgress;
   461 AddProgress;
   442 AddBorder(tmpsurf);
   462 AddBorder(tmpsurf);
   443 with PixelFormat^ do
   463 with PixelFormat^ do
   444      LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, 0);
   464      LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, 0);
   445 SDL_FillRect(LandSurface, nil, 0);
   465 SDL_FillRect(LandSurface, nil, 0);
       
   466 AddProgress;
   446 
   467 
   447 AddObjects(LandSurface);
   468 AddObjects(LandSurface);
   448 
   469 
   449 SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0);
   470 SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0);
   450 SDL_UpperBlit(tmpsurf, nil, LandSurface, nil);
   471 SDL_UpperBlit(tmpsurf, nil, LandSurface, nil);