sheepluva's basic 45° test. NEEDS TESTING
authornemo
Mon, 12 Oct 2009 13:47:56 +0000
changeset 2425 a4af95e6382c
parent 2424 b52344de23ae
child 2426 9d674c5c828d
sheepluva's basic 45° test. NEEDS TESTING
hedgewars/GSHandlers.inc
hedgewars/uLandTemplates.pas
--- 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;
--- a/hedgewars/uLandTemplates.pas	Mon Oct 12 13:44:34 2009 +0000
+++ b/hedgewars/uLandTemplates.pas	Mon Oct 12 13:47:56 2009 +0000
@@ -1917,7 +1917,7 @@
         18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
         28, 29, 30, 31, 32, 33, 34, 35, 37, 38
       );
-const CavernTemplates: array[0..5] of Longword = (36, 15, 2, 3, 21, 29);
+const CavernTemplates: array[0..4] of Longword = (36, 2, 3, 21, 29);
 const WackyTemplates: array[0..3] of Longword = (37, 38, 39, 40);
 
 implementation