hedgewars/uGearsHandlersRope.pas
changeset 9683 a342837fc875
parent 9681 69a1e18330c0
child 9706 5178d2263521
equal deleted inserted replaced
9681:69a1e18330c0 9683:a342837fc875
   166             cd:= -1
   166             cd:= -1
   167         else
   167         else
   168             cd:= 1;
   168             cd:= 1;
   169 
   169 
   170         // apply gravity if there is no obstacle
   170         // apply gravity if there is no obstacle
   171         if not (TestCollisionXwithXYShift(HHGear, _1*cd, 0, cd, true)) then
   171         if not (TestCollisionXwithXYShift(HHGear, _2*cd, 0, cd, true)) then
   172             HHGear^.dY := HHGear^.dY + cGravity * 16;
   172             HHGear^.dY := HHGear^.dY + cGravity * 16;
   173 
   173 
   174         if (GameFlags and gfMoreWind) <> 0 then
   174         if (GameFlags and gfMoreWind) <> 0 then
   175             // apply wind if there's no obstacle
   175             // apply wind if there's no obstacle
   176             if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then
   176             if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then
   193     ty := HHGear^.Y;
   193     ty := HHGear^.Y;
   194 
   194 
   195     if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then
   195     if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then
   196         if not (TestCollisionXwithXYShift(HHGear, _2*hwSign(ropeDx), 0, hwSign(ropeDx), true)
   196         if not (TestCollisionXwithXYShift(HHGear, _2*hwSign(ropeDx), 0, hwSign(ropeDx), true)
   197         or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(ropeDy), hwSign(ropeDy)))) then
   197         or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(ropeDy), hwSign(ropeDy)))) then
   198         //or TestCollisionXwithXYShift(HHGear, _1*hwSign(ropeDx), 0, hwSign(ropeDx), true)) then
       
   199             Gear^.Elasticity := Gear^.Elasticity + _1_2;
   198             Gear^.Elasticity := Gear^.Elasticity + _1_2;
   200 
   199 
   201     if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then
   200     if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then
   202         if not (TestCollisionXwithXYShift(HHGear, -_2*hwSign(ropeDx), 0, -hwSign(ropeDx), true)
   201         if not (TestCollisionXwithXYShift(HHGear, -_2*hwSign(ropeDx), 0, -hwSign(ropeDx), true)
   203         or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*-hwSign(ropeDy), -hwSign(ropeDy)))) then
   202         or ((ropeDy.QWordValue <> 0) and TestCollisionYwithXYShift(HHGear, 0, 1*-hwSign(ropeDy), -hwSign(ropeDy)))) then
   204         //or TestCollisionXwithXYShift(HHGear, -_1*hwSign(ropeDx), 0, -hwSign(ropeDx))) then
       
   205             Gear^.Elasticity := Gear^.Elasticity - _1_2;
   203             Gear^.Elasticity := Gear^.Elasticity - _1_2;
   206 
   204 
   207     HHGear^.X := Gear^.X + mdX * Gear^.Elasticity;
   205     HHGear^.X := Gear^.X + mdX * Gear^.Elasticity;
   208     HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity;
   206     HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity;
   209 
   207 
   315                     end;
   313                     end;
   316                 end
   314                 end
   317             end;
   315             end;
   318 
   316 
   319     haveCollision := false;
   317     haveCollision := false;
   320     if TestCollisionXwithXYShift(HHGear, _1*hwSign(HHGear^.dX), 0, hwSign(HHGear^.dX), true) then
   318     if TestCollisionXwithXYShift(HHGear, _2*hwSign(HHGear^.dX), 0, hwSign(HHGear^.dX), true) then
   321         begin
   319         begin
   322         HHGear^.dX := -_0_6 * HHGear^.dX;
   320         HHGear^.dX := -_0_6 * HHGear^.dX;
   323         haveCollision := true
   321         haveCollision := true
   324         end;
   322         end;
   325     if TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(HHGear^.dY), hwSign(HHGear^.dY)) then
   323     if TestCollisionYwithXYShift(HHGear, 0, 1*hwSign(HHGear^.dY), hwSign(HHGear^.dY)) then