patch by nemo: water bouncing + some tweaks
authorunc0rr
Thu, 26 Mar 2009 13:59:27 +0000
changeset 1918 975d5061712f
parent 1917 c94045b70142
child 1919 390d3f685a80
patch by nemo: water bouncing + some tweaks
hedgewars/GSHandlers.inc
hedgewars/uGears.pas
hedgewars/uLandObjects.pas
--- a/hedgewars/GSHandlers.inc	Thu Mar 26 13:54:02 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Thu Mar 26 13:59:27 2009 +0000
@@ -19,14 +19,32 @@
 procedure doStepDrowningGear(Gear: PGear); forward;
 
 function CheckGearDrowning(Gear: PGear): boolean;
+var skipSpeed, skipAngle, skipDecay: hwFloat;
 begin
+// probably needs tweaking. might need to be in a case statement based upon gear type
+//(not Gear^.dY.isNegative) and  this should not be necessary
 if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then
-	begin
-	CheckGearDrowning:= true;
-	Gear^.State:= gstDrowning;
-	Gear^.doStep:= @doStepDrowningGear;
-	PlaySound(sndSplash, false, nil)
-	end else
+    begin
+    skipSpeed:= _0_25;  // was 0.36 - couldn't manage baseball bat. Tiy's build is 0.36...
+    skipAngle:= _1 + _0_9;  // these should perhaps also be constants, once work out what proper values are
+    skipDecay:= _0_87;  // this could perhaps be a tiny bit higher.
+    if  ((Gear^.dX*Gear^.dX+Gear^.dY*Gear^.dY) > skipSpeed) and
+        (hwAbs(Gear^.dX/Gear^.dY) > skipAngle) then
+       begin
+       Gear^.dY.isNegative:= true;
+       Gear^.dY:=Gear^.dY*skipDecay;
+       Gear^.dX:=Gear^.dX*skipDecay;
+       CheckGearDrowning:= false
+       end
+    else
+        begin
+        CheckGearDrowning:= true;
+        Gear^.State:= gstDrowning;
+        Gear^.doStep:= @doStepDrowningGear;
+        end;
+    PlaySound(sndSplash, false, nil)
+    end
+    else
 	CheckGearDrowning:= false
 end;
 
--- a/hedgewars/uGears.pas	Thu Mar 26 13:54:02 2009 +0000
+++ b/hedgewars/uGears.pas	Thu Mar 26 13:59:27 2009 +0000
@@ -510,6 +510,7 @@
 	stChDmg: if CheckNoDamage then inc(step) else step:= stDelay;
 	stSweep: if SweepDirty then
 				begin
+				SetAllToActive;
 				step:= stChDmg
 				end else inc(step);
 	stTurnReact: begin
--- a/hedgewars/uLandObjects.pas	Thu Mar 26 13:54:02 2009 +0000
+++ b/hedgewars/uLandObjects.pas	Thu Mar 26 13:59:27 2009 +0000
@@ -179,8 +179,8 @@
 		repeat
 		inc(x2, 2);
 		k:= CountNonZeroz(x2, y)
-		until (x2 > (rightX-150)) or (k = 0) or (k = 16) or (x2 > i);
-		if (x2 < (rightX-150)) and (k = 16) and (x2 - x1 > 250)
+		until (x2 >= (rightX-150)) or (k = 0) or (k = 16) or (x2 > i) or (x2 - x1 >= 768);
+		if (x2 < (rightX - 150)) and (k = 16) and (x2 - x1 > 250) and (x2 - x1 < 768)
 			and not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144) then break;
 		end;
 x1:= 0;