hedgewars/uGears.pas
changeset 4830 c5ddc3e6c8a4
parent 4826 d6a0a38407c8
child 4833 204d26924532
equal deleted inserted replaced
4829:1d555e738a3a 4830:c5ddc3e6c8a4
  1092 var i: LongInt;
  1092 var i: LongInt;
  1093     Gear: PGear;
  1093     Gear: PGear;
  1094 begin
  1094 begin
  1095 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
  1095 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
  1096 
  1096 
  1097 for i:= 0 to Pred(cLandMines) do
  1097 i:= 0;
       
  1098 Gear:= PGear(1);
       
  1099 while (i < cLandMines) and (Gear <> nil) do
  1098     begin
  1100     begin
  1099     Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
  1101     Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
  1100     FindPlace(Gear, false, 0, LAND_WIDTH);
  1102     FindPlace(Gear, false, 0, LAND_WIDTH);
  1101     end;
  1103     inc(i)
  1102 for i:= 0 to Pred(cExplosives) do
  1104     end;
       
  1105 
       
  1106 i:= 0;
       
  1107 Gear:= PGear(1);
       
  1108 while (i < cExplosives) and (Gear <> nil) do
  1103     begin
  1109     begin
  1104     Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0);
  1110     Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0);
  1105     FindPlace(Gear, false, 0, LAND_WIDTH);
  1111     FindPlace(Gear, false, 0, LAND_WIDTH);
       
  1112     inc(i)
  1106     end;
  1113     end;
  1107 
  1114 
  1108 if (GameFlags and gfLowGravity) <> 0 then
  1115 if (GameFlags and gfLowGravity) <> 0 then
  1109     begin
  1116     begin
  1110     cGravity:= cMaxWindSpeed;
  1117     cGravity:= cMaxWindSpeed;
  1424 
  1431 
  1425 function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray;
  1432 function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray;
  1426 var
  1433 var
  1427     t: PGear;
  1434     t: PGear;
  1428 begin
  1435 begin
       
  1436     r:= r*r;
  1429     GearsNear := nil;
  1437     GearsNear := nil;
  1430     t := GearsList;
  1438     t := GearsList;
  1431     while t <> nil do begin
  1439     while t <> nil do begin
  1432         if (t^.Kind = Kind) then begin
  1440         if (t^.Kind = Kind) then begin
  1433             if (X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) <
  1441             if (X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) <
  1434                 int2hwFloat(r)*int2hwFloat(r) then
  1442                 int2hwFloat(r) then
  1435             begin
  1443             begin
  1436                 SetLength(GearsNear, Length(GearsNear)+1);
  1444                 SetLength(GearsNear, Length(GearsNear)+1);
  1437                 GearsNear[High(GearsNear)] := t;
  1445                 GearsNear[High(GearsNear)] := t;
  1438             end;
  1446             end;
  1439         end;
  1447         end;