hedgewars/uGearsHandlersRope.pas
changeset 7657 347e18494fb9
parent 7656 e7bef1a4fda7
child 7658 70a874a26414
--- a/hedgewars/uGearsHandlersRope.pas	Mon Sep 03 00:00:54 2012 -0400
+++ b/hedgewars/uGearsHandlersRope.pas	Mon Sep 03 12:35:51 2012 -0400
@@ -98,32 +98,31 @@
 procedure doStepRopeWork(Gear: PGear);
 var 
     HHGear: PGear;
-    len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY, sDx, sDy: hwFloat;
-    i, lx, ly, cd: LongInt;
+    len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat;
+    lx, ly, cd: LongInt;
     haveCollision,
     haveDivided: boolean;
 
 begin
-    if GameTicks mod 8 <> 0 then exit;
+    if GameTicks mod 4 <> 0 then exit;
 
     HHGear := Gear^.Hedgehog^.Gear;
 
     if ((HHGear^.State and gstHHDriven) = 0)
        or (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
         begin
+        HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shr 2;
+        HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shr 2;
         PlaySound(sndRopeRelease);
         RopeDeleteMe(Gear, HHGear);
         exit
         end;
 
-    HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shl 3;
-    HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shl 3;
-
     if (Gear^.Message and gmLeft  <> 0) and (not TestCollisionXwithGear(HHGear, -1)) then
-        HHGear^.dX := HHGear^.dX - _0_0128;
+        HHGear^.dX := HHGear^.dX - _0_0032;
 
     if (Gear^.Message and gmRight <> 0) and (not TestCollisionXwithGear(HHGear,  1)) then
-        HHGear^.dX := HHGear^.dX + _0_0128;
+        HHGear^.dX := HHGear^.dX + _0_0032;
 
     // vector between hedgehog and rope attaching point
     ropeDx := HHGear^.X - Gear^.X;
@@ -141,12 +140,12 @@
 
         // apply gravity if there is no obstacle
         if not TestCollisionXwithGear(HHGear, cd) then
-            HHGear^.dY := HHGear^.dY + cGravity * 64;
+            HHGear^.dY := HHGear^.dY + cGravity * 16;
 
         if (GameFlags and gfMoreWind) <> 0 then
             // apply wind if there's no obstacle
             if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then
-                HHGear^.dX := HHGear^.dX + cWindSpeed * 64 / HHGear^.Density;
+                HHGear^.dX := HHGear^.dX + cWindSpeed * 16 / HHGear^.Density;
         end;
 
     mdX := ropeDx + HHGear^.dX;
@@ -167,34 +166,18 @@
     if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then
         if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx))
         or (TestCollisionYwithGear(HHGear, hwSign(ropeDy)) <> 0)) then
-            Gear^.Elasticity := Gear^.Elasticity + _2_4;
+            Gear^.Elasticity := Gear^.Elasticity + _1_2;
 
     if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then
         if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx))
         or (TestCollisionYwithGear(HHGear, -hwSign(ropeDy)) <> 0)) then
-            Gear^.Elasticity := Gear^.Elasticity - _2_4;
+            Gear^.Elasticity := Gear^.Elasticity - _1_2;
 
     HHGear^.X := Gear^.X + mdX * Gear^.Elasticity;
     HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity;
 
-    HHGear^.dX := Gear^.X + mdX * Gear^.Elasticity - tx;
-    HHGear^.dY := Gear^.Y + mdY * Gear^.Elasticity - ty;
-
-    sDx:= HHGear^.dX / 8;
-    sDy:= HHGear^.dY / 8;
-
-    HHGear^.X:= tx;
-    HHGear^.Y:= ty;
-
-    i:= 0;
-    while not ((i = 8)
-        or TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX))
-        or (TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0)) do
-        begin
-        inc(i);
-        HHGear^.X:= HHGear^.X + sDx;
-        HHGear^.Y:= HHGear^.Y + sDy;
-        end;
+    HHGear^.dX := HHGear^.X - tx;
+    HHGear^.dY := HHGear^.Y - ty;
     ////
 
 
@@ -204,8 +187,8 @@
     len := Gear^.Elasticity - _5;
     nx := Gear^.X + mdX * len;
     ny := Gear^.Y + mdY * len;
-    tx := mdX * _2_4; // should be the same as increase step
-    ty := mdY * _2_4;
+    tx := mdX * _1_2; // should be the same as increase step
+    ty := mdY * _1_2;
 
     while len > _3 do
         begin
@@ -246,8 +229,8 @@
         nx := nx - tx;
         ny := ny - ty;
 
-        // len := len - _2_4 // should be the same as increase step
-        len.QWordValue := len.QWordValue - _2_4.QWordValue;
+        // len := len - _1_2 // should be the same as increase step
+        len.QWordValue := len.QWordValue - _1_2.QWordValue;
         end;
 
     if not haveDivided then
@@ -289,14 +272,14 @@
 
     if haveCollision and (Gear^.Message and (gmLeft or gmRight) <> 0) and (Gear^.Message and (gmUp or gmDown) <> 0) then
         begin
-        HHGear^.dX := SignAs(hwAbs(HHGear^.dX) + _1_6, HHGear^.dX);
-        HHGear^.dY := SignAs(hwAbs(HHGear^.dY) + _1_6, HHGear^.dY)
+        HHGear^.dX := SignAs(hwAbs(HHGear^.dX) + _0_8, HHGear^.dX);
+        HHGear^.dY := SignAs(hwAbs(HHGear^.dY) + _0_8, HHGear^.dY)
         end;
 
     len := hwSqr(HHGear^.dX) + hwSqr(HHGear^.dY);
-    if len > _49 then
+    if len > _10 then
         begin
-        len := _7 / hwSqrt(len);
+        len := _3_2 / hwSqrt(len);
         HHGear^.dX := HHGear^.dX * len;
         HHGear^.dY := HHGear^.dY * len;
         end;
@@ -342,6 +325,9 @@
         begin
         if (Gear^.State and gsttmpFlag) <> 0 then
             begin
+            HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shr 2;
+            HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shr 2;
+            
             PlaySound(sndRopeRelease);
             if Gear^.Hedgehog^.CurAmmoType <> amParachute then
                 RopeWaitCollision(Gear, HHGear)
@@ -352,9 +338,6 @@
     else
         if (Gear^.State and gsttmpFlag) = 0 then
             Gear^.State := Gear^.State or gsttmpFlag;
-
-    HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shr 3;
-    HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shr 3;
 end;
 
 procedure RopeRemoveFromAmmo(Gear, HHGear: PGear);
@@ -418,6 +401,8 @@
                 PlaySound(sndRopeAttach);
                 with HHGear^ do
                     begin
+                    dX.QWordValue:= dX.QWordValue shl 2;
+                    dY.QWordValue:= dY.QWordValue shl 2;
                     State := State and (not (gstAttacking or gstHHJumping or gstHHHJump));
                     Message := Message and (not gmAttack)
                     end;
@@ -444,6 +429,8 @@
         PlaySound(sndRopeAttach);
         with HHGear^ do
             begin
+            dX.QWordValue:= dX.QWordValue shl 2;
+            dY.QWordValue:= dY.QWordValue shl 2;
             State := State and (not (gstAttacking or gstHHJumping or gstHHHJump));
             Message := Message and (not gmAttack)
             end;
@@ -477,4 +464,4 @@
     PlaySound(sndRopeShot)
 end;
 
-end.
\ No newline at end of file
+end.