Hat 'wearing' animation
authorunc0rr
Thu, 11 Sep 2008 15:30:04 +0000
changeset 1251 1f545d9a10ca
parent 1250 180b044f09b7
child 1252 2e2719c0a397
Hat 'wearing' animation
hedgewars/uGears.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
--- a/hedgewars/uGears.pas	Wed Sep 10 14:37:27 2008 +0000
+++ b/hedgewars/uGears.pas	Thu Sep 11 15:30:04 2008 +0000
@@ -843,23 +843,34 @@
 		end;
 	end;
 
-
-if defaultPos then
+with PHedgehog(Gear^.Hedgehog)^ do
 	begin
-	DrawRotatedF(sprHHIdle,
-		hwRound(Gear^.X) + 1 + WorldDx,
-		hwRound(Gear^.Y) - 3 + WorldDy,
-		(RealTicks div 128 + Gear^.Pos) mod 19,
-		hwSign(Gear^.dX),
-		0);
-	DrawTextureF(PHedgehog(Gear^.Hedgehog)^.HatTex,
-		hwRound(Gear^.X) + 1 + WorldDx,
-		hwRound(Gear^.Y) - 8 + WorldDy,
-		(RealTicks div 128 + Gear^.Pos) mod 19,
-		hwSign(Gear^.dX),
-		32);
+	if defaultPos then
+		begin
+		DrawRotatedF(sprHHIdle,
+			hwRound(Gear^.X) + 1 + WorldDx,
+			hwRound(Gear^.Y) - 3 + WorldDy,
+			(RealTicks div 128 + Gear^.Pos) mod 19,
+			hwSign(Gear^.dX),
+			0);
+		if HatVisibility < 1.0 then
+			HatVisibility:= HatVisibility + 0.05;
+		end
+	else
+		if HatVisibility > 0.0 then
+			HatVisibility:= HatVisibility - 0.05;
+
+	if HatVisibility > 0 then
+		DrawTextureF(HatTex,
+			HatVisibility,
+			hwRound(Gear^.X) + 1 + WorldDx,
+			hwRound(Gear^.Y) - 8 + WorldDy,
+			(RealTicks div 128 + Gear^.Pos) mod 19,
+			hwSign(Gear^.dX),
+			32);
 	end;
 
+
 with PHedgehog(Gear^.Hedgehog)^ do
 	begin
 	if ((Gear^.State and not gstWinner) = 0)
--- a/hedgewars/uStore.pas	Wed Sep 10 14:37:27 2008 +0000
+++ b/hedgewars/uStore.pas	Thu Sep 11 15:30:04 2008 +0000
@@ -30,7 +30,7 @@
 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture);
 procedure DrawLand (X, Y: LongInt);
 procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
-procedure DrawTextureF(Texture: PTexture; X, Y, Frame, Dir, Frames: LongInt);
+procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, Frames: LongInt);
 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: 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);
@@ -357,12 +357,13 @@
 glEnd()
 end;
 
-procedure DrawTextureF(Texture: PTexture; X, Y, Frame, Dir, Frames: LongInt);
+procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, Frames: LongInt);
 var ft, fb: GLfloat;
 	hw: LongInt;
 begin
 glPushMatrix;
 glTranslatef(X, Y, 0);
+glScalef(Scale, Scale, 1.0);
 
 if Dir < 0 then
 	hw:= - 16
--- a/hedgewars/uTeams.pas	Wed Sep 10 14:37:27 2008 +0000
+++ b/hedgewars/uTeams.pas	Thu Sep 11 15:30:04 2008 +0000
@@ -18,7 +18,7 @@
 
 unit uTeams;
 interface
-uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats;
+uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, GL;
 {$INCLUDE options.inc}
 
 type PHHAmmo = ^THHAmmo;
@@ -40,6 +40,7 @@
                  AttacksNum: Longword;
                  visStepPos: LongWord;
                  BotLevel  : LongWord; // 0 - Human player
+                 HatVisibility: GLfloat;
                  stats: TStatistics;
                  Hat: String;
                  end;