# HG changeset patch # User unc0rr # Date 1134766634 0 # Node ID c374fe590272bb074f5359a2d12205e334e93108 # Parent e32fa14529f8f5330b9b0868083f710028a287aa - improve land generation - don't use themes with no objects diff -r e32fa14529f8 -r c374fe590272 hedgewars/Data/Themes/themes.cfg --- a/hedgewars/Data/Themes/themes.cfg Wed Dec 07 20:36:55 2005 +0000 +++ b/hedgewars/Data/Themes/themes.cfg Fri Dec 16 20:57:14 2005 +0000 @@ -1,7 +1,4 @@ avematan bubbles -ethereal -norsk tibet -wood xtheme diff -r e32fa14529f8 -r c374fe590272 hedgewars/uLand.pas --- a/hedgewars/uLand.pas Wed Dec 07 20:36:55 2005 +0000 +++ b/hedgewars/uLand.pas Fri Dec 16 20:57:14 2005 +0000 @@ -348,9 +348,9 @@ inc(t, 2) until (y > 1023) or (CountNonZeroz(x, y) <> 0); if (t > 22) and (y < 1023) then AddHHPoint(x, y - 12); - inc(y, 100) + inc(y, 80) end; - inc(x, 120) + inc(x, 100) end; if HHPoints.Last < cMaxHHs then @@ -371,8 +371,8 @@ end; procedure PointWave(var Template: TEdgeTemplate; var pa: TPixAr); -const MAXPASSES = 16; -var ar: array[1..MAXPASSES, 0..5] of real; +const MAXPASSES = 32; +var ar: array[0..MAXPASSES, 0..5] of real; i, k: integer; rx, ry, oy: real; PassesNum: Longword; @@ -381,13 +381,15 @@ begin PassesNum:= PassMin + getrandom(PassDelta); TryDo(PassesNum < MAXPASSES, 'Passes number too big', true); + ar[0, 1]:= WaveFreqMin; + ar[0, 4]:= WaveFreqMin; for i:= 1 to PassesNum do // initialize random parameters begin ar[i, 0]:= WaveAmplMin + getrandom * WaveAmplDelta; - ar[i, 1]:= WaveFreqMin + getrandom * WaveFreqDelta; + ar[i, 1]:= ar[i - 1, 1] + (getrandom * 0.7 + 0.3) * WaveFreqDelta; ar[i, 2]:= getrandom * pi * 2; ar[i, 3]:= WaveAmplMin + getrandom * WaveAmplDelta; - ar[i, 4]:= WaveFreqMin + getrandom * WaveFreqDelta; + ar[i, 4]:= ar[i - 1, 4] + (getrandom * 0.7 + 0.3) * WaveFreqDelta; ar[i, 5]:= getrandom * pi * 2; end; end; @@ -413,6 +415,24 @@ begin with Template do begin + if canMirror then + if getrandom(16) < 8 then + begin + for i:= 0 to pred(BasePointsCount) do + BasePoints^[i].x:= 2047 - BasePoints^[i].x; + for i:= 0 to pred(FillPointsCount) do + FillPoints^[i].x:= 2047 - FillPoints^[i].x; + end; + + if canFlip then + if getrandom(16) < 8 then + begin + for i:= 0 to pred(BasePointsCount) do + BasePoints^[i].y:= 1023 - BasePoints^[i].y; + for i:= 0 to pred(FillPointsCount) do + FillPoints^[i].y:= 1023 - FillPoints^[i].y; + end; + pa.Count:= BasePointsCount; for i:= 0 to pred(pa.Count) do pa.ar[i]:= BasePoints^[i]; @@ -443,6 +463,7 @@ with PixelFormat^ do LandSurface:= SDL_CreateRGBSurface(SDL_HWSURFACE, 2048, 1024, BitsPerPixel, RMask, GMask, BMask, 0); SDL_FillRect(LandSurface, nil, 0); +AddProgress; AddObjects(LandSurface); diff -r e32fa14529f8 -r c374fe590272 hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Wed Dec 07 20:36:55 2005 +0000 +++ b/hedgewars/uLandObjects.pas Fri Dec 16 20:57:14 2005 +0000 @@ -8,8 +8,8 @@ implementation uses uLand, uStore, uConsts, uMisc, uConsole, uRandom; -const MaxRects = 1024; - MAXOBJECTRECTS = 32; +const MaxRects = 256; + MAXOBJECTRECTS = 16; type PRectArray = ^TRectsArray; TRectsArray = array[0..MaxRects] of TSDL_rect; @@ -110,7 +110,7 @@ until (i = RectCount) or (Result) end; -procedure AddGirders(Surface: PSDL_Surface); +function AddGirder(gX: integer; Surface: PSDL_Surface): boolean; var tmpsurf: PSDL_Surface; x1, x2, y, k, i: integer; r, rr: TSDL_Rect; @@ -124,11 +124,11 @@ end; begin -y:= 256; +y:= 150; repeat inc(y, 24); - x1:= 1024; - x2:= 1024; + x1:= gX; + x2:= gX; while (x1 > 100) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); i:= x1 - 12; repeat @@ -151,6 +151,7 @@ until y > 900; if x1 > 0 then begin + Result:= true; tmpsurf:= LoadImage(Pathz[ptGraphics] + 'Girder.png'); rr.x:= x1; rr.y:= y; @@ -165,10 +166,10 @@ r.h:= 16; SDL_UpperBlit(tmpsurf, @r, Surface, @rr); SDL_FreeSurface(tmpsurf); - AddRect(x1 - 8, y - 8, x2 - x1 + 8, 32); + AddRect(x1 - 8, y - 8, x2 - x1 + 16, 72); for k:= y to y + 15 do for i:= x1 to x2 do Land[k, i]:= $FFFFFF - end + end else Result:= false end; function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean; @@ -187,7 +188,7 @@ i:= 0; while (i <= rect.h) and Result do begin - Result:= (Land[rect.y + i, rect.x] = Color) or (Land[rect.y + i, rect.x + rect.w] = Color); + Result:= (Land[rect.y + i, rect.x] = Color) and (Land[rect.y + i, rect.x + rect.w] = Color); inc(i) end; {$WARNINGS ON} @@ -236,9 +237,9 @@ x:= 5000; end end; - inc(y, 2); + inc(y, 3); until y > 1023 - Height; - inc(x, getrandom(8) + 2) + inc(x, getrandom(6) + 3) until x > 2047 - Width; Result:= cnt <> 0; if Result then @@ -251,7 +252,7 @@ end; procedure AddThemeObjects(Surface: PSDL_Surface; MaxCount: Longword); -const MAXTHEMEOBJECTS = 16; +const MAXTHEMEOBJECTS = 32; var f: textfile; s: string; ThemeObjects: array[1..MAXTHEMEOBJECTS] of TThemeObject; @@ -301,8 +302,11 @@ procedure AddObjects(Surface: PSDL_Surface); begin InitRects; -AddGirders(Surface); -AddThemeObjects(Surface, 5); +AddGirder(512, Surface); +AddGirder(1024, Surface); +AddGirder(1300, Surface); +AddGirder(1536, Surface); +AddThemeObjects(Surface, 8); FreeRects end; diff -r e32fa14529f8 -r c374fe590272 hedgewars/uLandTemplates.pas --- a/hedgewars/uLandTemplates.pas Wed Dec 07 20:36:55 2005 +0000 +++ b/hedgewars/uLandTemplates.pas Fri Dec 16 20:57:14 2005 +0000 @@ -14,6 +14,7 @@ WaveFreqMin, WaveFreqDelta: real; FillPoints: PPointArray; FillPointsCount: Longword; + canMirror, canFlip: boolean; end; const Template0Points: array[0..4] of TPoint = @@ -34,7 +35,7 @@ (x: 300; y: 1500), (x: 300; y: 1000), (x: 250; y: 750), - (x: 1023; y: 600), + (x: 1200; y: 500), (x: 1800; y: 750), (x: 1750; y: 1000), (x: 1750; y: 1500) @@ -44,11 +45,14 @@ (x: 1023; y: 1023) ); -const Template2Points: array[0..18] of TPoint = +const Template2Points: array[0..21] of TPoint = ( (x: 350; y: 1500), (x: 350; y: 1000), - (x: 190; y: 650), + (x: 190; y: 850), + (x: 500; y: 750), + (x: 520; y: 450), + (x: 190; y: 600), (x: 210; y: 260), (x: 1650; y: 220), (x: 1650; y: 460), @@ -72,34 +76,138 @@ (x: 1500; y: 1023) ); -const EdgeTemplates: array[0..2] of TEdgeTemplate = +const Template3Points: array[0..23] of TPoint = + ( + (x: 200; y: 1500), + (x: 200; y: 1000), + (x: 390; y: 650), + (x: 210; y: 260), + (x: 1000; y: 420), + (x: 1100; y: 200), + (x: 1250; y: 420), + (x: 1250; y: 620), + (x: 900; y: 610), + (x: 650; y: 450), + (x: 550; y: 500), + (x: 650; y: 700), + (x: 1200; y: 800), + (x: 1200; y: 1000), + (x: 1200; y: 1200), + (x: 1400; y: 1200), + (x: 1400; y: 1000), + (x: 1280; y: 750), + (x: 1500; y: 600), + (x: 1400; y: 200), + (x: 1800; y: 200), + (x: 1700; y: 600), + (x: 1900; y: 1010), + (x: 1800; y: 1200) + ); + Template3FPoints: array[0..1] of TPoint = + ( + (x: 500; y: 1023), + (x: 1500; y: 1023) + ); + +const Template4Points: array[0..38] of TPoint = + ( + (x: 200; y: 1500), + (x: 200; y: 1000), + (x: 210; y: 800), + (x: 480; y: 830), + (x: 460; y: 700), + (x: 150; y: 610), + (x: 150; y: 310), + (x: 220; y: 200), + (x: 340; y: 195), + (x: 410; y: 415), + (x: 420; y: 495), + (x: 535; y: 615), + (x: 705; y: 600), + (x: 760; y: 425), + (x: 815; y: 230), + (x: 970; y: 200), + (x: 1050; y: 360), + (x: 850; y: 590), + (x: 1070; y: 790), + (x: 1000; y: 1000), + (x: 1000; y: 1500), + (x: 1250; y: 1500), + (x: 1250; y: 1000), + (x: 1260; y: 830), + (x: 1290; y: 700), + (x: 1270; y: 450), + (x: 1180; y: 280), + (x: 1210; y: 160), + (x: 1370; y: 160), + (x: 1505; y: 205), + (x: 1630; y: 315), + (x: 1660; y: 450), + (x: 1580; y: 620), + (x: 1670; y: 725), + (x: 1800; y: 730), + (x: 1860; y: 680), + (x: 1925; y: 810), + (x: 1800; y: 1000), + (x: 1800; y: 1500) + ); + Template4FPoints: array[0..1] of TPoint = + ( + (x: 500; y: 1023), + (x: 1500; y: 1023) + ); + +const EdgeTemplates: array[0..4] of TEdgeTemplate = ( (BasePoints: @Template0Points; BasePointsCount: Succ(High(Template0Points)); BezPassCnt: 4; - PassMin: 4; PassDelta: 1; - WaveAmplMin: 27; WaveAmplDelta: 22; - WaveFreqMin: 0.010; WaveFreqDelta: 0.015; + PassMin: 10; PassDelta: 5; + WaveAmplMin: 17; WaveAmplDelta: 20; + WaveFreqMin: 0.010; WaveFreqDelta: 0.002; FillPoints: @Template0FPoints; FillPointsCount: Succ(High(Template0FPoints)); + canMirror: false; canFlip: false; ), (BasePoints: @Template1Points; BasePointsCount: Succ(High(Template1Points)); BezPassCnt: 4; - PassMin: 5; PassDelta: 2; - WaveAmplMin: 20; WaveAmplDelta: 10; - WaveFreqMin: 0.015; WaveFreqDelta: 0.020; + PassMin: 10; PassDelta: 2; + WaveAmplMin: 25; WaveAmplDelta: 15; + WaveFreqMin: 0.008; WaveFreqDelta: 0.002; FillPoints: @Template1FPoints; FillPointsCount: Succ(High(Template1FPoints)); + canMirror: false; canFlip: false; ), (BasePoints: @Template2Points; BasePointsCount: Succ(High(Template2Points)); BezPassCnt: 3; - PassMin: 3; PassDelta: 2; - WaveAmplMin: 30; WaveAmplDelta: 15; - WaveFreqMin: 0.010; WaveFreqDelta: 0.015; + PassMin: 14; PassDelta: 3; + WaveAmplMin: 10; WaveAmplDelta: 10; + WaveFreqMin: 0.010; WaveFreqDelta: 0.002; FillPoints: @Template2FPoints; FillPointsCount: Succ(High(Template2FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template3Points; + BasePointsCount: Succ(High(Template3Points)); + BezPassCnt: 4; + PassMin: 15; PassDelta: 2; + WaveAmplMin: 8; WaveAmplDelta: 12; + WaveFreqMin: 0.015; WaveFreqDelta: 0.0015; + FillPoints: @Template3FPoints; + FillPointsCount: Succ(High(Template3FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template4Points; + BasePointsCount: Succ(High(Template4Points)); + BezPassCnt: 3; + PassMin: 19; PassDelta: 5; + WaveAmplMin: 12; WaveAmplDelta: 14; + WaveFreqMin: 0.008; WaveFreqDelta: 0.001; + FillPoints: @Template4FPoints; + FillPointsCount: Succ(High(Template4FPoints)); + canMirror: true; canFlip: false; ) );