let players affect in which direction their teleported hedgehog will look
authorsheepluva
Thu, 29 Apr 2010 19:21:40 +0000
changeset 3378 4f2185ed8ca8
parent 3377 a3f0849f26bc
child 3379 f73e0e8e55c2
let players affect in which direction their teleported hedgehog will look
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uGears.pas
share/hedgewars/Data/Graphics/amTeleport.png
--- a/hedgewars/GSHandlers.inc	Thu Apr 29 18:53:22 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Thu Apr 29 19:21:40 2010 +0000
@@ -1992,6 +1992,10 @@
         DeleteCI(HHGear);
         SetAllHHToActive;
         Gear^.doStep:= @doStepTeleportAnim;
+        // copy old HH position and direction to Gear (because we need them for drawing the vanishing hog)
+        Gear^.dX:= HHGear^.dX;
+         // retrieve the cursor direction (it was previously copied to X so it doesn't get lost)
+         HHGear^.dX.isNegative := (Gear^.X.QWordValue <> 0);
         Gear^.X:= HHGear^.X;
         Gear^.Y:= HHGear^.Y;
         HHGear^.X:= int2hwFloat(TargetPoint.X);
--- a/hedgewars/HHHandlers.inc	Thu Apr 29 18:53:22 2010 +0000
+++ b/hedgewars/HHHandlers.inc	Thu Apr 29 19:21:40 2010 +0000
@@ -169,11 +169,12 @@
                                  PlaySound(sndBaseballBat) // TODO: Only play if something is hit?
                                  end;
                     amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0);
+                    // we save Ammo^[CurSlot, CurAmmo].Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear.
                     amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0);
                    amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
                     amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0);
                        amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0);
-                     amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0);
+                     amTeleport: CurAmmoGear:= AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtTeleport, 0, _0, _0, 0);
                        amSwitch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSwitcher, 0, _0, _0, 0);
                        amMortar: begin
                 playSound(sndMortar);
--- a/hedgewars/uGears.pas	Thu Apr 29 18:53:22 2010 +0000
+++ b/hedgewars/uGears.pas	Thu Apr 29 19:21:40 2010 +0000
@@ -1726,7 +1726,7 @@
          gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
         gtTeleport: begin
                     HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
-                    if not PHedgehog(Gear^.Hedgehog)^.Unplaced then DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0);
+                    if not PHedgehog(Gear^.Hedgehog)^.Unplaced then DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(Gear^.dX), 0);
                     DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
                     end;
         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12);
Binary file share/hedgewars/Data/Graphics/amTeleport.png has changed