hedgewars/GSHandlers.inc
changeset 2998 5b74906c14bb
parent 2995 b90745d87332
child 3001 a1d1e0d0067a
equal deleted inserted replaced
2997:ca60b5638fff 2998:5b74906c14bb
   165 
   165 
   166 ////////////////////////////////////////////////////////////////////////////////
   166 ////////////////////////////////////////////////////////////////////////////////
   167 procedure doStepFallingGear(Gear: PGear);
   167 procedure doStepFallingGear(Gear: PGear);
   168 var isFalling, isCollV, isCollH: boolean;
   168 var isFalling, isCollV, isCollH: boolean;
   169     tmp: QWord;
   169     tmp: QWord;
       
   170     tdX, tdY: hwFloat;
   170 begin
   171 begin
   171 Gear^.State:= Gear^.State and not gstCollision;
   172 Gear^.State:= Gear^.State and not gstCollision;
   172 isCollV:= false; 
   173 isCollV:= false; 
   173 isCollH:= false;
   174 isCollH:= false;
       
   175 tdX:= Gear^.dX;
       
   176 tdY:= Gear^.dY;
   174 
   177 
   175 if Gear^.dY.isNegative then
   178 if Gear^.dY.isNegative then
   176     begin
   179     begin
   177     isFalling:= true;
   180     isFalling:= true;
   178     if TestCollisionYwithGear(Gear, -1) then
   181     if TestCollisionYwithGear(Gear, -1) then
   202     end 
   205     end 
   203 else if Gear^.AdvBounce and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then isCollH:= true;
   206 else if Gear^.AdvBounce and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then isCollH:= true;
   204 
   207 
   205 if isCollV and isCollH and Gear^.AdvBounce then
   208 if isCollV and isCollH and Gear^.AdvBounce then
   206        begin
   209        begin
   207        tmp:= Gear^.dX.QWordValue;
   210        Gear^.dX:= hwAbs(tdY)*hwSign(Gear^.dX)*Gear^.Elasticity*Gear^.Friction;
   208        Gear^.dX.QWordValue:= Gear^.dY.QWordValue;
   211        Gear^.dY:= hwAbs(tdX)*hwSign(Gear^.dY)*Gear^.Elasticity;
   209        Gear^.dY.QWordValue:= tmp;
   212        //tmp:= Gear^.dX.QWordValue;
       
   213        //Gear^.dX.QWordValue:= Gear^.dY.QWordValue;
       
   214        //Gear^.dY.QWordValue:= tmp;
   210        end;
   215        end;
   211 
   216 
   212 if isFalling then Gear^.dY:= Gear^.dY + cGravity;
   217 if isFalling then Gear^.dY:= Gear^.dY + cGravity;
   213 
   218 
   214 Gear^.X:= Gear^.X + Gear^.dX;
   219 Gear^.X:= Gear^.X + Gear^.dX;