hedgewars/HHHandlers.inc
changeset 5830 ea4d1fe665d7
parent 5829 3ec95dc2b249
child 5832 f730c8a9777b
equal deleted inserted replaced
5829:3ec95dc2b249 5830:ea4d1fe665d7
   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 
   773 isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1);
   797 isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1);
   774 if isFalling then
   798 if isFalling then
   775    begin
   799    begin
   776    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0;
   800    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0;
   777    Gear^.State:= Gear^.State or gstMoving;
   801    Gear^.State:= Gear^.State or gstMoving;