Smooth change wind bar
authorunc0rr
Thu, 25 Aug 2005 17:15:36 +0000
changeset 6 9c1f00e7b43e
parent 5 0dafbd19a04c
child 7 b472e4b1a106
Smooth change wind bar
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uTeams.pas
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Thu Aug 25 16:45:58 2005 +0000
+++ b/hedgewars/GSHandlers.inc	Thu Aug 25 17:15:36 2005 +0000
@@ -267,14 +267,23 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepActionTimer(Gear: PGear);
 begin
-dec(Gear.Timer);
 case Gear.State of
      gtsStartGame: begin
+                   dec(Gear.Timer);
                    AllInactive:= false;
                    if Gear.Timer > 0 then exit;
                    AddCaption('Let''s fight!', $FFFFFF, capgrpStartGame);
                    DeleteGear(Gear)
                    end;
+  gtsSmoothWindCh: begin
+                   if Gear.Timer = 0 then
+                      begin
+                      Gear.Timer:= 10;
+                      if WindBarWidth < Gear.Tag then inc(WindBarWidth)
+                         else if WindBarWidth > Gear.Tag then dec(WindBarWidth)
+                         else DeleteGear(Gear)
+                      end else dec(Gear.Timer)
+                   end;
      end;
 end;
 
--- a/hedgewars/uConsts.pas	Thu Aug 25 16:45:58 2005 +0000
+++ b/hedgewars/uConsts.pas	Thu Aug 25 17:15:36 2005 +0000
@@ -118,6 +118,7 @@
       gstHHThinking     = $00000800;
 
       gtsStartGame      = 1;
+      gtsSmoothWindCh   = 2;
 
       gm_Left   = $00000001;
       gm_Right  = $00000002;
--- a/hedgewars/uGears.pas	Thu Aug 25 16:45:58 2005 +0000
+++ b/hedgewars/uGears.pas	Thu Aug 25 17:15:36 2005 +0000
@@ -59,7 +59,7 @@
              Hedgehog: pointer;
              Health, Damage: LongWord;
              CollIndex: Longword;
-             Tag: Longword;
+             Tag: integer;
              end;
 
 function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
--- a/hedgewars/uTeams.pas	Thu Aug 25 16:45:58 2005 +0000
+++ b/hedgewars/uTeams.pas	Thu Aug 25 17:15:36 2005 +0000
@@ -122,6 +122,7 @@
      end;
 ResetKbd;
 cWindSpeed:= (GetRandom * 2 - 1) * cMaxWindSpeed;
+AddGear(0, 0, gtActionTimer, gtsSmoothWindCh).Tag:= round(72 * cWindSpeed / cMaxWindSpeed);
 {$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
 ApplyAmmoChanges(@CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog]);
 TurnTimeLeft:= cHedgehogTurnTime
--- a/hedgewars/uWorld.pas	Thu Aug 25 16:45:58 2005 +0000
+++ b/hedgewars/uWorld.pas	Thu Aug 25 17:15:36 2005 +0000
@@ -48,6 +48,7 @@
 var cntTicks: LongWord;
 {$ENDIF}
 var FollowGear: PGear = nil;
+    WindBarWidth: integer = 0;
 
 implementation
 uses uStore, uMisc, uConsts, uTeams, uIO;
@@ -201,28 +202,31 @@
 
 // Wind bar
 DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface);
-if cWindSpeed > 0 then
+if WindBarWidth > 0 then
    begin
-   t:= round(72 * cWindSpeed / cMaxWindSpeed);
    with StuffPoz[sWindR] do
         begin
+        {$WARNINGS OFF}
         r.x:= x + 8 - (RealTicks shr 6) mod 8;
+        {$WARNINGS ON}
         r.y:= y;
-        r.w:= t;
+        r.w:= WindBarWidth;
         r.h:= 13;
         end;
    DrawSpriteFromRect(r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface);
    end else
+ if WindBarWidth < 0 then
    begin
-   t:= - round(72 * cWindSpeed / cMaxWindSpeed);
    with StuffPoz[sWindL] do
         begin
-        r.x:= x + (RealTicks shr 6) mod 8;
+        {$WARNINGS OFF}
+        r.x:= x + (WindBarWidth + RealTicks shr 6) mod 8;
+        {$WARNINGS ON}
         r.y:= y;
-        r.w:= t;
+        r.w:= - WindBarWidth;
         r.h:= 13;
         end;
-   DrawSpriteFromRect(r, cScreenWidth - 106 - t, cScreenHeight - 28, 13, 0, Surface);
+   DrawSpriteFromRect(r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
    end;
 
 // Cursor