Hedgehog death animation
authorunc0rr
Thu, 24 Apr 2008 19:55:10 +0000
changeset 868 4884bce5e5eb
parent 867 dc7901b1120e
child 869 daddcd31ef34
Hedgehog death animation
hedgewars/HHHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
share/hedgewars/Data/Graphics/HHDeath.png
--- a/hedgewars/HHHandlers.inc	Thu Apr 24 15:40:39 2008 +0000
+++ b/hedgewars/HHHandlers.inc	Thu Apr 24 19:55:10 2008 +0000
@@ -162,11 +162,14 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepHedgehogDead(Gear: PGear);
+const frametime = 200;
+      timertime = frametime * 6;
 begin
 if Gear^.Timer > 1 then
 	begin
 	AllInactive:= false;
-	dec(Gear^.Timer)
+	dec(Gear^.Timer);
+	if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos)
 	end else
 if Gear^.Timer = 1 then
 	begin
@@ -178,8 +181,12 @@
 	end else // Gear^.Timer = 0
 	begin
 	AllInactive:= false;
+	Gear^.Z:= cCurrHHZ;
+	RemoveGearFromList(Gear);
+	InsertGearToList(Gear);
 	PlaySound(sndByeBye, false);
-	Gear^.Timer:= 1100
+	Gear^.Pos:= 0;
+	Gear^.Timer:= timertime
 	end
 end;
 
@@ -510,12 +517,14 @@
 
 if (Gear^.Health = 0) then
 	begin
-	if AllInactive then
+	if PrvInactive then
 		begin
 		Gear^.Timer:= 0;
-		Gear^.doStep:= @doStepHedgehogDead
+		Gear^.State:= Gear^.State or gstHHDeath;
+		Gear^.doStep:= @doStepHedgehogDead;
+		PrvInactive:= false;
+		AllInactive:= false
 		end;
-	AllInactive:= false;
 	exit
 	end;
 
--- a/hedgewars/uConsts.pas	Thu Apr 24 15:40:39 2008 +0000
+++ b/hedgewars/uConsts.pas	Thu Apr 24 19:55:10 2008 +0000
@@ -43,7 +43,7 @@
                    sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR,
                    sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun,
                    sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer,
-                   sprHandBlowTorch, sprBlowTorch, sprTeleport);
+                   sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath);
 
      TGearType  = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
@@ -168,6 +168,7 @@
       gstNoDamage       = $00001000;
       gstHHHJump        = $00002000;
       gstAnimation      = $00004000;
+      gstHHDeath        = $00008000;
 
       gm_Left   = $00000001;
       gm_Right  = $00000002;
@@ -368,7 +369,9 @@
                      (FileName: 'amBTorch_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
                       Width:  32; Height: 32; saveSurf: false),// sprBlowToch
                      (FileName:   'Teleport'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-                      Width:  64; Height: 32;saveSurf: false) // sprTeleport
+                      Width:  64; Height: 32; saveSurf: false),// sprTeleport
+                     (FileName:    'HHDeath'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+                      Width:  32; Height: 64; saveSurf: false) // sprHHDeath
                      );
 
       Soundz: array[TSound] of record
--- a/hedgewars/uGears.pas	Thu Apr 24 15:40:39 2008 +0000
+++ b/hedgewars/uGears.pas	Thu Apr 24 19:55:10 2008 +0000
@@ -21,6 +21,7 @@
 uses SDLh, uConsts, uFloat;
 {$INCLUDE options.inc}
 const AllInactive: boolean = false;
+      PrvInactive: boolean = false;
 
 type PGear = ^TGear;
      TGearStepProcedure = procedure (Gear: PGear);
@@ -387,6 +388,7 @@
              stAfterDelay, stSpawn, stNTurn) = stDelay;
 var Gear, t: PGear;
 begin
+PrvInactive:= AllInactive;
 AllInactive:= true;
 t:= GearsList;
 while t<>nil do
@@ -486,6 +488,11 @@
 	aAngle, dAngle: real;
 	defaultPos: boolean;
 begin
+if (Gear^.State and gstHHDeath) <> 0 then
+	begin
+	DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos);
+	exit
+	end;
 defaultPos:= true;
 
 hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
Binary file share/hedgewars/Data/Graphics/HHDeath.png has changed