Keep hog facing direction while on parachute
authorWuzzy <Wuzzy2@mail.ru>
Sat, 15 Jun 2019 12:58:01 +0200
changeset 15167 6b7d92fa4912
parent 15166 d47122a0e4b4
child 15168 5dc3e3f1c0f9
Keep hog facing direction while on parachute
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsList.pas
hedgewars/uGearsRender.pas
hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsHedgehog.pas	Sat Jun 15 12:10:42 2019 +0200
+++ b/hedgewars/uGearsHedgehog.pas	Sat Jun 15 12:58:01 2019 +0200
@@ -270,7 +270,7 @@
     newGear:  PGear;
     CurWeapon: PAmmo;
     usedAmmoType: TAmmoType;
-    altUse: boolean;
+    altUse, faceLeft: boolean;
     elastic: hwFloat;
 begin
 newGear:= nil;
@@ -414,7 +414,10 @@
                                  PlaySound(sndBaseballBat) // TODO: Only play if something is hit?
                                  end;
                     amParachute: begin
+                                 faceLeft:= IsHogFacingLeft(Gear);
                                  newGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0);
+                                 if faceLeft then
+                                     newGear^.Tag:= -1;
                                  PlaySound(sndParachute)
                                  end;
                     // we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear.
--- a/hedgewars/uGearsList.pas	Sat Jun 15 12:10:42 2019 +0200
+++ b/hedgewars/uGearsList.pas	Sat Jun 15 12:58:01 2019 +0200
@@ -330,7 +330,10 @@
                              ((GetRandom(90)+128) shl 16) or
                              (($d5+c) shl 8) or $ff}
                 end;
-   gtParachute: gear^.Z:= cCurrHHZ;
+   gtParachute: begin
+                gear^.Tag:= 1; // hog face dir. 1 = right, -1 = left
+                gear^.Z:= cCurrHHZ;
+                end;
        gtShell: begin
                 gear^.Elasticity:= _0_8;
                 gear^.Friction:= _0_8;
--- a/hedgewars/uGearsRender.pas	Sat Jun 15 12:10:42 2019 +0200
+++ b/hedgewars/uGearsRender.pas	Sat Jun 15 12:58:01 2019 +0200
@@ -662,6 +662,17 @@
                     dec(sy,20);
                     end;
                 gtTeleport: defaultPos:= false;
+                gtParachute:
+                    begin
+                    DrawSpriteRotatedF(sprHHIdle,
+                            sx,
+                            sy,
+                            0,
+                            CurAmmoGear^.Tag,
+                            0);
+                    HatVisible:= true;
+                    defaultPos:= false;
+                    end;
                 gtWhip:
                     begin
                     DrawSpriteRotatedF(sprWhip,
--- a/hedgewars/uGearsUtils.pas	Sat Jun 15 12:10:42 2019 +0200
+++ b/hedgewars/uGearsUtils.pas	Sat Jun 15 12:58:01 2019 +0200
@@ -1861,7 +1861,9 @@
 var sign: LongInt;
 begin
     sign:= hwSign(Gear^.dX);
-    if ((Gear^.State and gstHHHJump) <> 0) and (Gear^.Hedgehog^.Effects[heArtillery] = 0) then
+    if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtParachute) then
+        IsHogFacingLeft:= CurAmmoGear^.Tag = -1
+    else if ((Gear^.State and gstHHHJump) <> 0) and (Gear^.Hedgehog^.Effects[heArtillery] = 0) then
         IsHogFacingLeft:= sign > 0
     else
         IsHogFacingLeft:= sign < 0;