- Better gears placing
authorunc0rr
Sun, 04 Feb 2007 15:46:52 +0000
changeset 386 21eeb5ac0486
parent 385 9201c85f7ff4
child 387 66345e38826d
- Better gears placing - One more land template
hedgewars/uGears.pas
hedgewars/uLandTemplates.pas
--- a/hedgewars/uGears.pas	Sun Feb 04 15:24:24 2007 +0000
+++ b/hedgewars/uGears.pas	Sun Feb 04 15:46:52 2007 +0000
@@ -829,16 +829,16 @@
 
 var fx, x: LongInt;
     y, sy: LongInt;
-    ar: array[0..512] of TPoint;
-    cnt, delta: Longword;
+    ar: array[0..511] of TPoint;
+    ar2: array[0..1023] of TPoint;
+    cnt, cnt2, delta: Longword;
 begin
-fx:= Left + LongInt(GetRandom(Right - Left));
-x:= fx;
-delta:= 130;
+delta:= 250;
+cnt2:= 0;
 repeat
+  x:= Left + GetRandom(Delta);
   repeat
-     inc(x, Gear^.Radius);
-     if x > Right then x:= Left + (x mod (Right - left));
+     inc(x, Delta);
      cnt:= 0;
      y:= -Gear^.Radius * 2;
      while y < 1023 do
@@ -859,23 +859,32 @@
                        else ar[cnt].Y:= y - Gear^.Radius;
            inc(cnt)
            end;
-        inc(y, 80)
+        inc(y, 45)
         end;
      if cnt > 0 then
         with ar[GetRandom(cnt)] do
           begin
-          Gear^.X:= x;
-          Gear^.Y:= y;
-         {$IFDEF DEBUGFILE}
-         AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
-         {$ENDIF}
-          exit
+          ar2[cnt2].x:= x;
+          ar2[cnt2].y:= y;
+          inc(cnt2)
           end
-  until (x - Gear^.Radius < fx) and (x + Gear^.Radius > fx);
-dec(Delta, 20)
-until (Delta < 70);
-OutError('Couldn''t find place for Gear', false);
-DeleteGear(Gear)
+  until (x + Delta > Right);
+dec(Delta, 60)
+until (cnt2 > 0) or (Delta < 70);
+if cnt2 > 0 then
+   with ar2[GetRandom(cnt2)] do
+      begin
+      Gear^.X:= x;
+      Gear^.Y:= y;
+      {$IFDEF DEBUGFILE}
+      AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
+      {$ENDIF}
+      end
+   else
+   begin
+   OutError('Can''t find place for Gear', false);
+   DeleteGear(Gear)
+   end
 end;
 
 initialization
--- a/hedgewars/uLandTemplates.pas	Sun Feb 04 15:24:24 2007 +0000
+++ b/hedgewars/uLandTemplates.pas	Sun Feb 04 15:46:52 2007 +0000
@@ -171,7 +171,32 @@
        (x: 1023; y:    0)
       );
 
-const EdgeTemplates: array[0..4] of TEdgeTemplate =
+const Template5Points: array[0..15] of TSDL_Rect =
+      (
+       (x:  274; y: 1024; w:    1; h:    1),
+       (x:  190; y:  918; w:  168; h:   26),
+       (x:  382; y:  776; w:  122; h:  114),
+       (x:  568; y:  744; w:   56; h:  180),
+       (x:  678; y:  856; w:   64; h:   56),
+       (x:  740; y:  650; w:  106; h:  220),
+       (x:  644; y:  496; w:  162; h:  140),
+       (x:  796; y:  260; w:  286; h:  174),
+       (x:  934; y:  448; w:  296; h:  108),
+       (x:  950; y:  752; w:  152; h:  146),
+       (x: 1172; y:  774; w:   60; h:  152),
+       (x: 1284; y:  722; w:  150; h:  138),
+       (x: 1494; y:  564; w:   56; h:  382),
+       (x: 1620; y:  774; w:   94; h:  132),
+       (x: 1612; y: 1024; w:    1; h:    1),
+       (x: NTPX; y:    0; w:    1; h:    1)
+       );
+
+      Template5FPoints: array[0..0] of TPoint =
+      (
+       (x: 1023; y:    0)
+      );
+
+const EdgeTemplates: array[0..5] of TEdgeTemplate =
       (
        (BasePoints: @Template0Points;
         BasePointsCount: Succ(High(Template0Points));
@@ -207,6 +232,13 @@
         FillPointsCount: Succ(High(Template4FPoints));
         RandPassesCount: 3;
         canMirror: false; canFlip: false;
+       ),
+       (BasePoints: @Template5Points;
+        BasePointsCount: Succ(High(Template5Points));
+        FillPoints: @Template5FPoints;
+        FillPointsCount: Succ(High(Template5FPoints));
+        RandPassesCount: 3;
+        canMirror: true; canFlip: false;
        )
       );