Properly set dx/dy of hedgehog on parachute
authorWuzzy <Wuzzy2@mail.ru>
Sat, 15 Jun 2019 12:10:42 +0200
changeset 15150 d47122a0e4b4
parent 15149 59c595191eba
child 15151 6b7d92fa4912
Properly set dx/dy of hedgehog on parachute
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sat Jun 15 12:09:12 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Jun 15 12:10:42 2019 +0200
@@ -2971,7 +2971,7 @@
 procedure doStepParachuteWork(Gear: PGear);
 var
     HHGear: PGear;
-    deltaX: hwFloat;
+    deltaX, deltaY: hwFloat;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
 
@@ -2999,6 +2999,7 @@
 
     deltaX:= _0;
     deltaX:= deltaX + cWindSpeed * 200;
+    deltaY:= _0;
 
     if (Gear^.Message and gmLeft) <> 0 then
         deltaX := deltaX - cMaxWindSpeed * 80
@@ -3007,16 +3008,24 @@
         deltaX := deltaX + cMaxWindSpeed * 80;
 
     if (Gear^.Message and gmUp) <> 0 then
-        HHGear^.Y := HHGear^.Y - cGravity * 40
+        deltaY := deltaY - cGravity * 40
 
     else if (Gear^.Message and gmDown) <> 0 then
-        HHGear^.Y := HHGear^.Y + cGravity * 40;
+        deltaY := deltaY + cGravity * 40;
 
     HHGear^.X := HHGear^.X + deltaX;
     // don't drift into obstacles
     if TestCollisionXwithGear(HHGear, hwSign(deltaX)) <> 0 then
+        begin
         HHGear^.X := HHGear^.X - int2hwFloat(hwSign(deltaX));
-    HHGear^.Y := HHGear^.Y + cGravity * 100;
+        deltaX:= _0;
+        end;
+    deltaY := deltaY + cGravity * 100;
+    HHGear^.Y := HHGear^.Y + deltaY;
+
+    HHGear^.dX := deltaX;
+    HHGear^.dY := deltaY;
+
     Gear^.X := HHGear^.X;
     Gear^.Y := HHGear^.Y
 end;