equal
deleted
inserted
replaced
827 FindPlace(Gear, withFall, Left, Right, false); |
827 FindPlace(Gear, withFall, Left, Right, false); |
828 end; |
828 end; |
829 |
829 |
830 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
830 procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
831 var x: LongInt; |
831 var x: LongInt; |
832 y, sy: LongInt; |
832 y, sy, dir: LongInt; |
833 ar: array[0..1023] of TPoint; |
833 ar: array[0..1023] of TPoint; |
834 ar2: array[0..2047] of TPoint; |
834 ar2: array[0..2047] of TPoint; |
835 temp: TPoint; |
835 temp: TPoint; |
836 cnt, cnt2: Longword; |
836 cnt, cnt2: Longword; |
837 delta: LongInt; |
837 delta: LongInt; |
848 while tryAgain do |
848 while tryAgain do |
849 begin |
849 begin |
850 delta:= LAND_WIDTH div 16; |
850 delta:= LAND_WIDTH div 16; |
851 cnt2:= 0; |
851 cnt2:= 0; |
852 repeat |
852 repeat |
853 x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
853 if GetRandom(2) = 0 then dir:= -1 else dir:= 1; |
|
854 x:= max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
|
855 if dir = 1 then x:= Left + x else x:= Right - x; |
854 repeat |
856 repeat |
855 cnt:= 0; |
857 cnt:= 0; |
856 y:= min(1024, topY) - Gear^.Radius shl 1; |
858 y:= min(1024, topY) - Gear^.Radius shl 1; |
857 while y < cWaterLine do |
859 while y < cWaterLine do |
858 begin |
860 begin |
898 with temp do |
900 with temp do |
899 begin |
901 begin |
900 ar2[cnt2].x:= x; |
902 ar2[cnt2].x:= x; |
901 ar2[cnt2].y:= y; |
903 ar2[cnt2].y:= y; |
902 inc(cnt2) |
904 inc(cnt2) |
903 end |
905 end; |
904 end; |
906 end; |
905 inc(x, Delta) |
907 inc(x, Delta*dir) |
906 until (x > Right); |
908 until ((dir = 1) and (x > Right)) or ((dir = -1) and (x < Left)); |
907 |
909 |
908 dec(Delta, 60) |
910 dec(Delta, 60) |
909 until (cnt2 > 0) or (Delta < 70); |
911 until (cnt2 > 0) or (Delta < 70); |
910 // if either of these has not been tried, do another pass |
912 // if either of these has not been tried, do another pass |
911 if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
913 if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |