# HG changeset patch # User nemo # Date 1268714581 0 # Node ID a1d1e0d0067afc0f6862e5026ba6649511891ae4 # Parent 2b9405b6dc5df5a9f1abd6973c4d3e25ddabba48 Still fiddling with bouncing, hoping to make it work diff -r 2b9405b6dc5d -r a1d1e0d0067a hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Mon Mar 15 11:54:47 2010 +0000 +++ b/hedgewars/GSHandlers.inc Tue Mar 16 04:43:01 2010 +0000 @@ -165,13 +165,14 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepFallingGear(Gear: PGear); -var isFalling, isCollV, isCollH: boolean; +var isFalling: boolean; tmp: QWord; tdX, tdY: hwFloat; + collV, collH: LongInt; begin Gear^.State:= Gear^.State and not gstCollision; -isCollV:= false; -isCollH:= false; +collV:= 0; +collH:= 0; tdX:= Gear^.dX; tdY:= Gear^.dY; @@ -180,7 +181,7 @@ isFalling:= true; if TestCollisionYwithGear(Gear, -1) then begin - isCollV:= true; + collV:= -1; Gear^.dX:= Gear^.dX * Gear^.Friction; Gear^.dY:= - Gear^.dY * Gear^.Elasticity; Gear^.State:= Gear^.State or gstCollision @@ -188,7 +189,7 @@ end else if TestCollisionYwithGear(Gear, 1) then begin - isCollV:= true; + collV:= 1; isFalling:= false; Gear^.dX:= Gear^.dX * Gear^.Friction; Gear^.dY:= - Gear^.dY * Gear^.Elasticity; @@ -198,21 +199,24 @@ if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then begin - isCollH:= true; + collH:= hwSign(Gear^.dX); Gear^.dX:= - Gear^.dX * Gear^.Elasticity; Gear^.dY:= Gear^.dY * Gear^.Elasticity; Gear^.State:= Gear^.State or gstCollision end -else if Gear^.AdvBounce and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then isCollH:= true; +else if Gear^.AdvBounce and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then collH:= -hwSign(Gear^.dX); -if isCollV and isCollH and Gear^.AdvBounce then - begin - Gear^.dX:= hwAbs(tdY)*hwSign(Gear^.dX)*Gear^.Elasticity*Gear^.Friction; - Gear^.dY:= hwAbs(tdX)*hwSign(Gear^.dY)*Gear^.Elasticity; - //tmp:= Gear^.dX.QWordValue; - //Gear^.dX.QWordValue:= Gear^.dY.QWordValue; - //Gear^.dY.QWordValue:= tmp; - end; +if (collV <>0) and (collH <> 0) and Gear^.AdvBounce then + begin + Gear^.dX:= tdY*Gear^.Elasticity*Gear^.Friction; + Gear^.dY:= tdX*Gear^.Elasticity*Gear^.Friction; + if ((collV > 0) and (collH > 0)) or ((collV < 0) and (collH < 0)) then Gear^.dX.isNegative:=not tdY.isNegative + else if (collV < 0) and (collH > 0) then Gear^.dY.isNegative:= not tdX.isNegative; + + //tmp:= Gear^.dX.QWordValue; + //Gear^.dX.QWordValue:= Gear^.dY.QWordValue; + //Gear^.dY.QWordValue:= tmp; + end; if isFalling then Gear^.dY:= Gear^.dY + cGravity;