Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
authorunc0rr
Fri, 26 Dec 2008 19:34:05 +0000
changeset 1551 c747e69f98f3
parent 1550 2331fe280aef
child 1552 cd907418da91
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc	Thu Dec 25 12:30:00 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Fri Dec 26 19:34:05 2008 +0000
@@ -630,6 +630,7 @@
 var HHGear: PGear;
 	len, cs, cc, tx, ty, nx, ny, ropeDx, ropeDy: hwFloat;
 	lx, ly: LongInt;
+	haveCollision: boolean;
 
 	procedure DeleteMe;
 	begin
@@ -736,10 +737,23 @@
 HHGear^.X:= Gear^.X + cc*Gear^.Elasticity;
 HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity;
 
+haveCollision:= false;
 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
+	begin
 	HHGear^.dX:= -_0_6 * HHGear^.dX;
+	haveCollision:= true
+	end;
 if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then
+	begin
 	HHGear^.dY:= -_0_6 * HHGear^.dY;
+	haveCollision:= true
+	end;
+
+if haveCollision and (Gear^.Message and (gm_Left or gm_Right) <> 0) then
+	begin
+	HHGear^.dX:= SignAs(hwAbs(HHGear^.dX) + _0_15, HHGear^.dX);
+	HHGear^.dY:= SignAs(hwAbs(HHGear^.dY) + _0_15, HHGear^.dY)
+	end;
 
 len:= Distance(HHGear^.dX, HHGear^.dY);
 if len > _0_8 then