hedgewars/uGearsHandlersRope.pas
changeset 7652 db731c523653
parent 7648 796ff8debbbc
child 7656 e7bef1a4fda7
equal deleted inserted replaced
7651:4cd85eebc54b 7652:db731c523653
    99 var 
    99 var 
   100     HHGear: PGear;
   100     HHGear: PGear;
   101     len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY, sDx, sDy: hwFloat;
   101     len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY, sDx, sDy: hwFloat;
   102     i, lx, ly, cd: LongInt;
   102     i, lx, ly, cd: LongInt;
   103     haveCollision,
   103     haveCollision,
   104     haveDivided: boolean;
   104     haveDivided, bx, by: boolean;
   105 
   105 
   106 begin
   106 begin
   107     if GameTicks mod 8 <> 0 then exit;
   107     if GameTicks mod 8 <> 0 then exit;
   108 
   108 
   109     HHGear := Gear^.Hedgehog^.Gear;
   109     HHGear := Gear^.Hedgehog^.Gear;
   178     HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity;
   178     HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity;
   179 
   179 
   180     HHGear^.dX := Gear^.X + mdX * Gear^.Elasticity - tx;
   180     HHGear^.dX := Gear^.X + mdX * Gear^.Elasticity - tx;
   181     HHGear^.dY := Gear^.Y + mdY * Gear^.Elasticity - ty;
   181     HHGear^.dY := Gear^.Y + mdY * Gear^.Elasticity - ty;
   182 
   182 
   183     sDx:= HHGear^.dX / 8;
   183     sDx:= HHGear^.dX / 4;
   184     sDy:= HHGear^.dY / 8;
   184     sDy:= HHGear^.dY / 4;
   185 
   185 
   186     HHGear^.X:= tx;
   186     HHGear^.X:= tx;
   187     HHGear^.Y:= ty;
   187     HHGear^.Y:= ty;
   188 
   188 
   189     i:= 0;
   189     i:= 0;
   190     while not ((i = 8)
   190     bx:= TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX));
   191         or TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX))
   191     by:= TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0;
   192         or (TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0)) do
   192     while not ((i = 4)
       
   193         or bx
       
   194         or by) do
   193         begin
   195         begin
   194         inc(i);
   196         inc(i);
   195         HHGear^.X:= HHGear^.X + sDx;
   197         HHGear^.X:= HHGear^.X + sDx;
   196         HHGear^.Y:= HHGear^.Y + sDy;
   198         HHGear^.Y:= HHGear^.Y + sDy;
       
   199         bx:= TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX));
       
   200         by:= TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0;
   197         end;
   201         end;
   198     ////
   202     ////
   199 
   203 
       
   204     if not bx then HHGear^.dX:= HHGear^.X - tx;
       
   205     if not by then HHGear^.dY:= HHGear^.Y - ty;
   200 
   206 
   201     haveDivided := false;
   207     haveDivided := false;
   202     // check whether rope needs dividing
   208     // check whether rope needs dividing
   203 
   209 
   204     len := Gear^.Elasticity - _5;
   210     len := Gear^.Elasticity - _5;