# HG changeset patch # User Wuzzy # Date 1547390834 -3600 # Node ID ca9c632db2cfe2c933ab8991fc054985e207390f # Parent af22a14c6a232c5303da9db738579a3f4fb9941e Bounce off gears at bouncy world edge only if they move towards it diff -r af22a14c6a23 -r ca9c632db2cf hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Sun Jan 13 05:00:14 2019 +0100 +++ b/hedgewars/uGearsUtils.pas Sun Jan 13 15:47:14 2019 +0100 @@ -1746,7 +1746,7 @@ Trying to make the checks a little broader than on first pass to catch things that don't move normally. *) function WorldWrap(var Gear: PGear): boolean; -//var tdx: hwFloat; +var bounced: boolean; begin WorldWrap:= false; if WorldEdge = weNone then exit(false); @@ -1763,19 +1763,22 @@ end else if WorldEdge = weBounce then begin - if (hwRound(Gear^.X) - Gear^.Radius < leftX) then + bounced:= false; + if (hwRound(Gear^.X) - Gear^.Radius < leftX) and (hwSign(Gear^.dX) = -1) and (not isZero(Gear^.dX)) then begin LeftImpactTimer:= 333; Gear^.dX.isNegative:= false; - Gear^.X:= int2hwfloat(leftX + Gear^.Radius) + Gear^.X:= int2hwfloat(leftX + Gear^.Radius); + bounced:= true; end - else + else if (hwRound(Gear^.X) - Gear^.Radius > rightX) and (hwSign(Gear^.dX) = 1) and (not isZero(Gear^.dX)) then begin RightImpactTimer:= 333; Gear^.dX.isNegative:= true; - Gear^.X:= int2hwfloat(rightX-Gear^.Radius) + Gear^.X:= int2hwfloat(rightX-Gear^.Radius); + bounced:= true; end; - if (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then + if (bounced) and (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then AddBounceEffectForGear(Gear); end{ else if WorldEdge = weSea then