Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
authornemo
Sun, 28 Jun 2009 18:47:55 +0000
changeset 2204 526f8165acce
parent 2203 6bd39d75e0dd
child 2205 e8573a7cab06
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Sun Jun 28 16:54:51 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Jun 28 18:47:55 2009 +0000
@@ -2224,9 +2224,12 @@
     end;
 
 if Gear^.Health < 0 then Gear^.Health:= 0;
-if (GameTicks and $3F) = 0 then AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', $FFFFFF, capgrpAmmostate);
-
-//AddCaption(inttostr(round(Gear^.Health/20))+'% : '+inttostr(round(Gear^.Timer/1000)), $FFFFFF, capgrpMessage);
+if (GameTicks and $3F) = 0 then 
+       begin
+//AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', $FFFFFF, capgrpAmmostate);
+       if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
+       Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', $FFFFFFFF, fntSmall)
+       end;
 
 HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Precise or gm_Left or gm_Right);
 HHGear^.State:= HHGear^.State or gstMoving; 
@@ -2253,7 +2256,9 @@
 		end;
 	DeleteGear(Gear);
 	isCursorVisible:= false;
-    AddCaption(trmsg[sidFuel]+': '+inttostr(round(Gear^.Health/20))+'%', $FFFFFF, capgrpAmmostate);
+//    if Gear^.Tex <> nil then FreeTexture(Gear^.Tex);
+//    Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', $FFFFFFFF, fntSmall)
+    //AddCaption(trmsg[sidFuel]+': '+inttostr(round(Gear^.Health/20))+'%', $FFFFFF, capgrpAmmostate);
 	end
 end;
 
--- a/hedgewars/uConsts.pas	Sun Jun 28 16:54:51 2009 +0000
+++ b/hedgewars/uConsts.pas	Sun Jun 28 18:47:55 2009 +0000
@@ -156,12 +156,12 @@
 	msgFailedSize        = 'failed due to size';
 	msgGettingConfig     = 'Getting game config...';
 
-const
-	ifNone        = $00000000;
-	ifAlpha       = $00000001;
-	ifCritical    = $00000002;
-	ifTransparent = $00000004;
-	ifIgnoreCaps  = $00000008;
+const // image flags (for LoadImage())
+    ifNone        = $00000000; // nothing special
+    ifAlpha       = $00000001; // use alpha channel (unused right now?)
+    ifCritical    = $00000002; // image is critical for gameplay (exit game if unable to load)
+    ifTransparent = $00000004; // image uses transparent pixels (color keying)
+    ifIgnoreCaps  = $00000008; // ignore hardware capabilities when loading (i.e. image won't be drawn using OpenGL)
 	
 const
 	cMaxPower     = 1500;
--- a/hedgewars/uGears.pas	Sun Jun 28 16:54:51 2009 +0000
+++ b/hedgewars/uGears.pas	Sun Jun 28 18:47:55 2009 +0000
@@ -29,6 +29,7 @@
 			NextGear, PrevGear: PGear;
 			Active: Boolean;
 			Invulnerable: Boolean;
+			RenderTimer: Boolean;
 			Ammo : PAmmo;
 			State : Longword;
 			X : hwFloat;
@@ -236,11 +237,13 @@
                 Result^.Radius:= 4;
                 Result^.Elasticity:= _0_6;
                 Result^.Friction:= _0_96;
+                Result^.RenderTimer:= true
                 end;
   gtWatermelon: begin
                 Result^.Radius:= 4;
                 Result^.Elasticity:= _0_8;
                 Result^.Friction:= _0_995;
+                Result^.RenderTimer:= true
                 end;
     gtHedgehog: begin
                 Result^.Radius:= cHHRadius;
@@ -251,6 +254,7 @@
                 end;
 gtAmmo_Grenade: begin
                 Result^.Radius:= 4;
+                Result^.RenderTimer:= true
                 end;
    gtHealthTag: begin
                 Result^.Timer:= 1500;
@@ -263,6 +267,7 @@
          gtUFO: begin
                 Result^.Radius:= 5;
                 Result^.Timer:= 500;
+                Result^.RenderTimer:= true;
                 Result^.Elasticity:= _0_9
                 end;
  gtShotgunShot: begin
@@ -317,7 +322,10 @@
                 Result^.Friction:= _0_03;
                 Result^.Timer:= 5000;
                 end;
-     gtCluster: Result^.Radius:= 2;
+     gtCluster: begin
+                Result^.Radius:= 2;
+                Result^.RenderTimer:= true
+                end;
       gtShover: Result^.Radius:= 20;
        gtFlame: begin
                 Result^.Tag:= Counter mod 32;
@@ -339,6 +347,7 @@
    gtBlowTorch: begin
                 Result^.Radius:= cHHRadius + cBlowTorchC;
                 Result^.Timer:= 7500;
+                Result^.RenderTimer:= true
                 end;
     gtSwitcher: begin
                 Result^.Z:= cCurrHHZ
@@ -361,16 +370,19 @@
                 Result^.Health:= 2048;
                 Result^.Radius:= 7;
                 Result^.Z:= cOnHHZ;
+                Result^.RenderTimer:= true;
                 if hwSign(dX) > 0 then Result^.Angle:= 1 else Result^.Angle:= 3
                 end;
  gtHellishBomb: begin
                 Result^.Radius:= 4;
                 Result^.Elasticity:= _0_5;
                 Result^.Friction:= _0_96;
+                Result^.RenderTimer:= true
                 end;
        gtDrill: begin
                 Result^.Timer:= 5000;
                 Result^.Radius:= 4;
+                Result^.RenderTimer:= true
                 end;
         gtBall: begin
                 Result^.Radius:= 5;
@@ -385,7 +397,7 @@
      gtRCPlane: begin
                 Result^.Timer:= 15000;
                 Result^.Health:= 3;
-                Result^.Radius:= 8;
+                Result^.Radius:= 8
                 end;
      gtJetpack: begin
                 Result^.Health:= 2000;
@@ -515,7 +527,15 @@
 	begin
 	Gear:= t;
 	t:= Gear^.NextGear;
-	if Gear^.Active then Gear^.doStep(Gear);
+	if Gear^.Active then 
+        begin
+        if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then
+            begin
+            if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); 
+            Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), $FFFFFFFF, fntSmall);
+            end;
+        Gear^.doStep(Gear);
+        end
 	end;
 
 if AllInactive then
@@ -1180,6 +1200,7 @@
 	                   if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1);
 	                   if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2);
 	                   if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3);
+                       if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex)
                        end;
             end;
         end
@@ -1398,6 +1419,7 @@
      gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
       gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
          end;
+      if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(hwRound(Gear^.X) + 8 + WorldDx, hwRound(Gear^.Y) + 8 + WorldDy, Gear^.Tex);
       Gear:= Gear^.NextGear
       end;
 end;