hedgewars/uCollisions.pas
changeset 3609 bc63ed514b70
parent 3608 c509bbc779e7
child 3697 d5b30d6373fc
equal deleted inserted replaced
3608:c509bbc779e7 3609:bc63ed514b70
    92     dec(Count)
    92     dec(Count)
    93     end;
    93     end;
    94 end;
    94 end;
    95 
    95 
    96 function CheckGearsCollision(Gear: PGear): PGearArray;
    96 function CheckGearsCollision(Gear: PGear): PGearArray;
    97 var mx, my: LongInt;
    97 var mx, my, tr: LongInt;
    98     i: Longword;
    98     i: Longword;
    99 begin
    99 begin
   100 CheckGearsCollision:= @ga;
   100 CheckGearsCollision:= @ga;
   101 ga.Count:= 0;
   101 ga.Count:= 0;
   102 if Count = 0 then exit;
   102 if Count = 0 then exit;
   103 mx:= hwRound(Gear^.X);
   103 mx:= hwRound(Gear^.X);
   104 my:= hwRound(Gear^.Y);
   104 my:= hwRound(Gear^.Y);
   105 
   105 
       
   106 tr:= Gear^.Radius + 2;
       
   107 
   106 for i:= 0 to Pred(Count) do
   108 for i:= 0 to Pred(Count) do
   107     with cinfos[i] do
   109     with cinfos[i] do
   108         if (Gear <> cGear) and
   110         if (Gear <> cGear) and
   109             (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
   111             (sqr(mx - x) + sqr(my - y) <= sqr(Radius + tr)) then
   110                 begin
   112                 begin
   111                 ga.ar[ga.Count]:= cinfos[i].cGear;
   113                 ga.ar[ga.Count]:= cinfos[i].cGear;
   112                 inc(ga.Count)
   114                 inc(ga.Count)
   113                 end
   115                 end
   114 end;
   116 end;