hedgewars/GSHandlers.inc
changeset 2989 b49d87499398
parent 2983 25b6b554c516
child 2994 7ae3067546f2
--- a/hedgewars/GSHandlers.inc	Sun Mar 14 16:56:02 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Mar 14 17:04:36 2010 +0000
@@ -164,15 +164,19 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepFallingGear(Gear: PGear);
-var isFalling: boolean;
+var isFalling, isCollV, isCollH: boolean;
+    tmp: QWord;
 begin
 Gear^.State:= Gear^.State and not gstCollision;
+isCollV:= false; 
+isCollH:= false;
 
 if Gear^.dY.isNegative then
     begin
     isFalling:= true;
     if TestCollisionYwithGear(Gear, -1) then
         begin
+        isCollV:= true;
         Gear^.dX:=   Gear^.dX * Gear^.Friction;
         Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
         Gear^.State:= Gear^.State or gstCollision
@@ -180,18 +184,29 @@
     end else
     if TestCollisionYwithGear(Gear, 1) then
         begin
+        isCollV:= true;
         isFalling:= false;
         Gear^.dX:=   Gear^.dX * Gear^.Friction;
         Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
         Gear^.State:= Gear^.State or gstCollision
         end else isFalling:= true;
 
+
 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
     begin
+    isCollH:= true;
     Gear^.dX:= - Gear^.dX * Gear^.Elasticity;
     Gear^.dY:=   Gear^.dY * Gear^.Elasticity;
     Gear^.State:= Gear^.State or gstCollision
-    end;
+    end 
+else if Gear^.AdvBounce and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then isCollH:= true;
+
+if isCollV and isCollH and Gear^.AdvBounce then
+       begin
+       tmp:= Gear^.dX.QWordValue;
+       Gear^.dX.QWordValue:= Gear^.dY.QWordValue;
+       Gear^.dY.QWordValue:= tmp;
+       end;
 
 if isFalling then Gear^.dY:= Gear^.dY + cGravity;