Teleport animation
authorunc0rr
Sun, 20 Apr 2008 10:39:08 +0000
changeset 853 0b4a23795530
parent 852 f756a1d3324c
child 854 fef7f2d908bf
Teleport animation
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uStore.pas
hedgewars/uVisualGears.pas
share/hedgewars/Data/Graphics/Teleport.png
--- a/hedgewars/GSHandlers.inc	Sat Apr 19 19:34:19 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Apr 20 10:39:08 2008 +0000
@@ -1154,16 +1154,18 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepTeleportAfter(Gear: PGear);
-//var HHGear: PGear;
 begin
-//HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
-//HHGear^.Y:= HHGear^.Y + HHGear^.dY;
-//HHGear^.dY:= HHGear^.dY + cGravity;
-//if TestCollisionYwithGear(HHGear, 1) then
-//   begin
-   DeleteGear(Gear);
-   AfterAttack
-//   end
+inc(Gear^.Timer);
+if Gear^.Timer = 65 then
+	begin
+	Gear^.Timer:= 0;
+	inc(Gear^.Pos);
+	if Gear^.Pos = 11 then
+		begin
+		DeleteGear(Gear);
+		AfterAttack
+		end
+	end
 end;
 
 procedure doStepTeleport(Gear: PGear);
@@ -1175,21 +1177,23 @@
 if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2,
                       TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2,
                       sprHHTelepMask, 0, false) then
-        begin
-        HHGear^.Message:= HHGear^.Message and not gm_Attack;
-        HHGear^.State:= HHGear^.State and not gstAttacking;
-        HHGear^.State:= HHGear^.State or gstHHChooseTarget;
-        DeleteGear(Gear);
-        isCursorVisible:= true
-        end
-   else begin
-        DeleteCI(HHGear);
-        SetAllHHToActive;
-        Gear^.doStep:= @doStepTeleportAfter;
-        HHGear^.X:= int2hwFloat(TargetPoint.X);
-        HHGear^.Y:= int2hwFloat(TargetPoint.Y);
-        HHGear^.State:= HHGear^.State or gstMoving
-        end;
+		begin
+		HHGear^.Message:= HHGear^.Message and not gm_Attack;
+		HHGear^.State:= HHGear^.State and not gstAttacking;
+		HHGear^.State:= HHGear^.State or gstHHChooseTarget;
+		DeleteGear(Gear);
+		isCursorVisible:= true
+		end
+	else begin
+		DeleteCI(HHGear);
+		SetAllHHToActive;
+		Gear^.doStep:= @doStepTeleportAfter;
+		Gear^.X:= HHGear^.X;
+		Gear^.Y:= HHGear^.Y;
+		HHGear^.X:= int2hwFloat(TargetPoint.X);
+		HHGear^.Y:= int2hwFloat(TargetPoint.Y);
+		HHGear^.State:= HHGear^.State or gstMoving
+		end;
 TargetPoint.X:= NoPointX
 end;
 
--- a/hedgewars/uConsts.pas	Sat Apr 19 19:34:19 2008 +0000
+++ b/hedgewars/uConsts.pas	Sun Apr 20 10:39:08 2008 +0000
@@ -43,7 +43,7 @@
                    sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR,
                    sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun,
                    sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer,
-                   sprHandBlowTorch, sprBlowTorch);
+                   sprHandBlowTorch, sprBlowTorch, sprTeleport);
 
      TGearType  = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
@@ -364,7 +364,9 @@
                      (FileName: 'amBTorch_i'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprHandBlowToch
                      (FileName: 'amBTorch_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  32; Height: 32; saveSurf: false) // sprBlowToch
+                      Width:  32; Height: 32; saveSurf: false),// sprBlowToch
+                     (FileName:   'Teleport'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+                      Width:  64; Height: 32;saveSurf: false) // sprTeleport
                      );
 
       Soundz: array[TSound] of record
--- a/hedgewars/uGears.pas	Sat Apr 19 19:34:19 2008 +0000
+++ b/hedgewars/uGears.pas	Sun Apr 20 10:39:08 2008 +0000
@@ -503,9 +503,8 @@
 						3,
 						0);
 				end;
-
-		else if (CurAmmoGear^.Kind = gtPickHammer) then
-			defaultPos:= false
+			gtPickHammer,
+			gtTeleport: defaultPos:= false;
 		end
 	end else
 	if ((Gear^.State and gstHHJumping) <> 0) then
@@ -560,6 +559,7 @@
 						1,
 						3,
 						0);
+			amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0);
 		else
 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
 				hwSign(Gear^.dX),
@@ -627,7 +627,7 @@
 end;
 
 procedure DrawGears(Surface: PSDL_Surface);
-var Gear: PGear;
+var Gear, HHGear: PGear;
     i: Longword;
     roplen: LongInt;
 
@@ -746,6 +746,11 @@
        gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 0)
                                      else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1);
          gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
+        gtTeleport: begin
+                    HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+                    DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.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);
           gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
               end;
--- a/hedgewars/uStore.pas	Sat Apr 19 19:34:19 2008 +0000
+++ b/hedgewars/uStore.pas	Sun Apr 20 10:39:08 2008 +0000
@@ -31,7 +31,7 @@
 procedure DrawLand (X, Y: LongInt);
 procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
-procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame: LongInt; Angle: real);
+procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
 procedure DrawCentered(X, Top: LongInt; Source: PTexture);
 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
@@ -380,13 +380,15 @@
 		X, Y, Dir, Angle)
 end;
 
-procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame: LongInt; Angle: real);
+procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real);
 begin
 glPushMatrix;
 glTranslatef(X, Y, 0);
 glRotatef(Angle, 0, 0, 1);
 
-DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Width div 2, Frame);
+if Dir < 0 then glScalef(-1.0, 1.0, 1.0);
+
+DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
 
 glPopMatrix
 end;
--- a/hedgewars/uVisualGears.pas	Sat Apr 19 19:34:19 2008 +0000
+++ b/hedgewars/uVisualGears.pas	Sun Apr 20 10:39:08 2008 +0000
@@ -158,7 +158,7 @@
            vgtFlake: if vobVelocity = 0 then
                         DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame)
                      else
-                        DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, Gear^.Angle);
+                        DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
 
            vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame);
               end;
Binary file share/hedgewars/Data/Graphics/Teleport.png has changed