hedgewars/GSHandlers.inc
changeset 2425 a4af95e6382c
parent 2424 b52344de23ae
child 2428 6800f8aa0184
--- a/hedgewars/GSHandlers.inc	Mon Oct 12 13:44:34 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Mon Oct 12 13:47:56 2009 +0000
@@ -108,15 +108,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
@@ -124,6 +128,7 @@
 	end else
 	if TestCollisionYwithGear(Gear, 1) then
 		begin
+		isCollV:= true;
 		isFalling:= false;
 		Gear^.dX:=   Gear^.dX * Gear^.Friction;
 		Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
@@ -132,9 +137,19 @@
 
 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 else
+	if TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then
+		isCollH:= true;
+
+if isCollV and isCollH 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;