hedgewars/HHHandlers.inc
changeset 5834 f9944a75b350
parent 5832 f730c8a9777b
child 5838 180ffae2c039
equal deleted inserted replaced
5833:d0c742472d46 5834:f9944a75b350
   768    Gear^.dY:= _0;
   768    Gear^.dY:= _0;
   769    Gear^.dX:= _0;
   769    Gear^.dX:= _0;
   770    Gear^.State:= Gear^.State and not gstMoving;
   770    Gear^.State:= Gear^.State and not gstMoving;
   771    exit
   771    exit
   772    end;
   772    end;
   773 
       
   774 // move hedgehogs out of walls
       
   775 if hwAbs(Gear^.dX) < _0_03 then
       
   776     begin
       
   777     if CountCollisionsX(Gear, -1) > Gear^.Radius then
       
   778         repeat
       
   779         Gear^.X:= Gear^.X + _1;
       
   780         if CountCollisionsX(Gear, 1) > Gear^.Radius then
       
   781             begin
       
   782             Gear^.X:= Gear^.X - _1;
       
   783             break;
       
   784             end
       
   785         until CountCollisionsX(Gear, -1) <= Gear^.Radius
       
   786     else if CountCollisionsX(Gear, 1) > Gear^.Radius then
       
   787         repeat
       
   788         Gear^.X:= Gear^. X - _1;
       
   789         if CountCollisionsX(Gear, -1) > Gear^.Radius then
       
   790             begin
       
   791             Gear^.X:= Gear^.X + _1;
       
   792             break;
       
   793             end
       
   794         until CountCollisionsX(Gear, 1) <= Gear^.Radius;
       
   795     end;
       
   796 
       
   797 isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1);
   773 isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1);
   798 if isFalling then
   774 if isFalling then
   799    begin
   775    begin
   800    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0;
   776    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0;
   801    Gear^.State:= Gear^.State or gstMoving;
   777    Gear^.State:= Gear^.State or gstMoving;