Desert Eagle and Shotgun shot animations
authorunc0rr
Sat, 26 Apr 2008 14:35:01 +0000
changeset 876 d5b6e0ae5755
parent 875 226d0de2fb68
child 877 ebb801acd8b9
Desert Eagle and Shotgun shot animations
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
share/hedgewars/Data/Graphics/Hedgehog/amDEagle.png
share/hedgewars/Data/Graphics/Hedgehog/amDEagle_w.png
share/hedgewars/Data/Graphics/Hedgehog/amShotgun.png
share/hedgewars/Data/Graphics/Hedgehog/amShotgun_w.png
--- a/hedgewars/GSHandlers.inc	Fri Apr 25 22:03:18 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Sat Apr 26 14:35:01 2008 +0000
@@ -284,37 +284,51 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
+procedure doStepShotIdle(Gear: PGear);
+begin
+AllInactive:= false;
+inc(Gear^.Timer);
+if Gear^.Timer > 75 then
+	begin
+	DeleteGear(Gear);
+	AfterAttack
+	end
+end;
+
 procedure doStepShotgunShot(Gear: PGear);
 var i: LongWord;
 begin
 AllInactive:= false;
-if Gear^.Timer > 0 then
-   begin
-   dec(Gear^.Timer);
-   if Gear^.Timer = 0 then PlaySound(sndShotgunFire, false);
-   exit
-   end;
+
+if ((Gear^.State and gstAnimation) = 0) then
+	begin
+	dec(Gear^.Timer);
+	if Gear^.Timer = 0 then
+		begin
+		PlaySound(sndShotgunFire, false);
+		Gear^.State:= Gear^.State or gstAnimation
+		end;
+	exit
+	end
+	else inc(Gear^.Timer);
+
 i:= 200;
 repeat
 Gear^.X:= Gear^.X + Gear^.dX;
 Gear^.Y:= Gear^.Y + Gear^.dY;
 CheckCollision(Gear);
 if (Gear^.State and gstCollision) <> 0 then
-   begin
-   Gear^.X:= Gear^.X + Gear^.dX * 8;
-   Gear^.Y:= Gear^.Y + Gear^.dY * 8;
-   ShotgunShot(Gear);
-   DeleteGear(Gear);
-   AfterAttack;
-   exit
-   end;
+	begin
+	Gear^.X:= Gear^.X + Gear^.dX * 8;
+	Gear^.Y:= Gear^.Y + Gear^.dY * 8;
+	ShotgunShot(Gear);
+	Gear^.doStep:= @doStepShotIdle;
+	exit
+	end;
 dec(i)
 until i = 0;
 if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then
-   begin
-   DeleteGear(Gear);
-   AfterAttack
-   end
+	Gear^.doStep:= @doStepShotIdle
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -323,6 +337,7 @@
     oX, oY: hwFloat;
 begin
 AllInactive:= false;
+inc(Gear^.Timer);
 i:= 80;
 oX:= Gear^.X;
 oY:= Gear^.Y;
@@ -343,7 +358,7 @@
    Gear^.Damage:= 0
    end;
 if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then
-   DeleteGear(Gear)
+	Gear^.doStep:= @doStepShotIdle
 end;
 
 procedure doStepDEagleShot(Gear: PGear);
--- a/hedgewars/HHHandlers.inc	Fri Apr 25 22:03:18 2008 +0000
+++ b/hedgewars/HHHandlers.inc	Sat Apr 26 14:35:01 2008 +0000
@@ -113,7 +113,7 @@
                                  AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000);
                                  PlaySound(sndLaugh, false)
                                  end;
-                       amDEagle: AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
+                       amDEagle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
                      amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
                   amBaseballBat: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0);
                     amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, _0, _0, 0);
--- a/hedgewars/uConsts.pas	Fri Apr 25 22:03:18 2008 +0000
+++ b/hedgewars/uConsts.pas	Sat Apr 26 14:35:01 2008 +0000
@@ -43,7 +43,8 @@
                    sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR,
                    sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun,
                    sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer,
-                   sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath);
+                   sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath,
+                   sprShotgun, sprDEagle);
 
      TGearType  = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
@@ -355,9 +356,9 @@
                      (FileName:  'amBazooka'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprHandBazooka
                      (FileName:  'amShotgun'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  32; Height: 32; saveSurf: false),// sprHandShotgun
+                      Width:  64; Height: 64; saveSurf: false),// sprHandShotgun
                      (FileName:   'amDEagle'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  32; Height: 32; saveSurf: false),// sprHandDEagle
+                      Width:  64; Height: 64; saveSurf: false),// sprHandDEagle
                      (FileName:'amAirAttack'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprHandAirAttack
                      (FileName: 'amBaseball'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
@@ -371,7 +372,11 @@
                      (FileName:   'Teleport'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  64; Height: 32; saveSurf: false),// sprTeleport
                      (FileName:    'HHDeath'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  32; Height: 64; saveSurf: false) // sprHHDeath
+                      Width:  32; Height: 64; saveSurf: false),// sprHHDeath
+                     (FileName:'amShotgun_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
+                      Width:  64; Height: 64; saveSurf: false),// sprShotgun
+                     (FileName: 'amDEagle_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
+                      Width:  64; Height: 64; saveSurf: false) // sprDEagle
                      );
 
       Soundz: array[TSound] of record
--- a/hedgewars/uGears.pas	Fri Apr 25 22:03:18 2008 +0000
+++ b/hedgewars/uGears.pas	Sat Apr 26 14:35:01 2008 +0000
@@ -509,7 +509,11 @@
 	if CurAmmoGear <> nil then
 	begin
 		case CurAmmoGear^.Kind of
-			gtShotgunShot: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
+			gtShotgunShot: if (CurAmmoGear^.State and gstAnimation <> 0) then
+					DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
+				else
+					DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
+			gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
 			gtRope: begin
 				if Gear^.X < CurAmmoGear^.X then
 					begin
@@ -538,6 +542,19 @@
 			gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
 			gtPickHammer,
 			gtTeleport: defaultPos:= false;
+		end;
+
+		case CurAmmoGear^.Kind of
+			gtShotgunShot,
+			gtDEagleShot,
+			gtShover: begin
+				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
+						hwSign(Gear^.dX),
+						0,
+						4,
+						0);
+				defaultPos:= false
+			end
 		end
 	end else
 
@@ -581,15 +598,6 @@
 		end;
 
 		case amt of
-			amBazooka,
-			amRope,
-			amShotgun,
-			amDEagle,
-			amBaseballBat: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
-						hwSign(Gear^.dX),
-						0,
-						4,
-						0);
 			amAirAttack,
 			amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0);
 			amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
Binary file share/hedgewars/Data/Graphics/Hedgehog/amDEagle.png has changed
Binary file share/hedgewars/Data/Graphics/Hedgehog/amDEagle_w.png has changed
Binary file share/hedgewars/Data/Graphics/Hedgehog/amShotgun.png has changed
Binary file share/hedgewars/Data/Graphics/Hedgehog/amShotgun_w.png has changed