No need for Extended data type just to draw some visual gears. It's a shame we have Math unit dependency
authorunC0Rr
Thu, 18 Nov 2010 15:55:02 +0300
changeset 4379 6cd6b77df8b8
parent 4378 91655618a510
child 4380 b78638b36b89
No need for Extended data type just to draw some visual gears. It's a shame we have Math unit dependency
hedgewars/VGSHandlers.inc
hedgewars/uTypes.pas
hedgewars/uVariables.pas
hedgewars/uVisualGears.pas
--- a/hedgewars/VGSHandlers.inc	Thu Nov 18 15:45:35 2010 +0300
+++ b/hedgewars/VGSHandlers.inc	Thu Nov 18 15:55:02 2010 +0300
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  *)
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
-var sign: float;
+var sign: real;
 begin
 if vobCount = 0 then exit;
 
@@ -59,8 +59,8 @@
         begin
         if round(X) < cLeftScreenBorder then X:= X + cScreenSpace else
         if round(X) > cRightScreenBorder then X:= X - cScreenSpace;
-        // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + float(25); // For if flag is set for flakes rising upwards?
-        if round(Y) - 75 > LAND_HEIGHT then Y:= Y - float(1024 + 150); // TODO - configure in theme (jellies for example could use limited range)
+        // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + 25.0; // For if flag is set for flakes rising upwards?
+        if round(Y) - 75 > LAND_HEIGHT then Y:= Y - (1024 + 150); // TODO - configure in theme (jellies for example could use limited range)
         Timer:= 0;
         tdX:= 0;
         tdY:= 0
@@ -81,7 +81,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepCloud(Gear: PVisualGear; Steps: Longword);
 var s: Longword;
-    t: float;
+    t: real;
 begin
 Gear^.X:= Gear^.X + (cWindSpeedf * 750 * Gear^.dX) * Steps;
 
@@ -479,7 +479,7 @@
 
 Gear^.doStep:= @doStepSpeechBubbleWork;
 
-Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h)
+Gear^.Y:= Gear^.Y - Gear^.Tex^.h
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -521,7 +521,7 @@
 else
     Gear^.doStep:= @doStepHealthTagWorkUnderWater;
 
-Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h);
+Gear^.Y:= Gear^.Y - Gear^.Tex^.h;
 
 if Steps > 1 then Gear^.doStep(Gear, Steps-1);
 end;
--- a/hedgewars/uTypes.pas	Thu Nov 18 15:45:35 2010 +0300
+++ b/hedgewars/uTypes.pas	Thu Nov 18 15:55:02 2010 +0300
@@ -220,12 +220,12 @@
         NextGear, PrevGear: PVisualGear;
         Frame,
         FrameTicks: Longword;
-        X : float;
-        Y : float;
-        dX: float;
-        dY: float;
-        tdX: float;
-        tdY: float;
+        X : real;
+        Y : real;
+        dX: real;
+        dY: real;
+        tdX: real;
+        tdY: real;
         State : Longword;
         Timer: Longword;
         Angle, dAngle: real;
--- a/hedgewars/uVariables.pas	Thu Nov 18 15:45:35 2010 +0300
+++ b/hedgewars/uVariables.pas	Thu Nov 18 15:55:02 2010 +0300
@@ -108,12 +108,12 @@
     CursorMovementX : LongInt;
     CursorMovementY : LongInt;
     cDrownSpeed     : hwFloat;
-    cDrownSpeedf    : float;
+    cDrownSpeedf    : real;
     cMaxWindSpeed   : hwFloat;
     cWindSpeed      : hwFloat;
-    cWindSpeedf     : float;
+    cWindSpeedf     : real;
     cGravity        : hwFloat;
-    cGravityf       : float;
+    cGravityf       : real;
     cDamageModifier : hwFloat;
     cLaserSighting  : boolean;
     cVampiric       : boolean;
--- a/hedgewars/uVisualGears.pas	Thu Nov 18 15:45:35 2010 +0300
+++ b/hedgewars/uVisualGears.pas	Thu Nov 18 15:55:02 2010 +0300
@@ -20,7 +20,7 @@
 
 unit uVisualGears;
 interface
-uses uConsts, uFloat, Math, GLunit, uTypes;
+uses uConsts, uFloat, GLunit, uTypes;
 
 procedure initModule;
 procedure freeModule;
@@ -34,7 +34,7 @@
 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
 
 implementation
-uses uMisc, uStore, uSound, uMobile, uVariables, uTextures, uRender;
+uses uMisc, uStore, uSound, uMobile, uVariables, uTextures, uRender, uUtils, Math;
 
 const cExplFrameTicks = 110;
 
@@ -98,7 +98,7 @@
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0): PVisualGear;
 var gear: PVisualGear;
     t: Longword;
-    sp: float;
+    sp: real;
 begin
 if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we are scrolling now
     if Kind <> vgtCloud then
@@ -124,8 +124,8 @@
 
 New(gear);
 FillChar(gear^, sizeof(TVisualGear), 0);
-gear^.X:= float(X);
-gear^.Y:= float(Y);
+gear^.X:= real(X);
+gear^.Y:= real(Y);
 gear^.Kind := Kind;
 gear^.doStep:= doStepHandlers[Kind];
 gear^.State:= 0;
@@ -351,7 +351,7 @@
       if Gear^.Kind = vgtFlake then
           begin
           // Damage calc from doMakeExplosion
-          dmg:= min(101, Radius + cHHRadius div 2 - LongInt(abs(round(Gear^.X) - X) + abs(round(Gear^.Y) - Y)) div 5);
+          dmg:= Min(101, Radius + cHHRadius div 2 - LongInt(abs(round(Gear^.X) - X) + abs(round(Gear^.Y) - Y)) div 5);
           if dmg > 1 then
               begin
               Gear^.tdX:= 0.02 * dmg + 0.01;
@@ -409,7 +409,7 @@
         case Gear^.Kind of
             vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State);
             vgtBigExplosion: begin
-                             Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
+                             Tint($FF, $FF, $FF, round($FF * (1 - power(Gear^.Timer / 250, 4))));
                              DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
                              end;
             end;
@@ -424,14 +424,14 @@
                 vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
                 vgtSteam: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
                 vgtAmmo: begin
-                        Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
+                        Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
                         DrawTextureF(ropeIconTex, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 32, 32);
                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
                         end;
                 vgtHealth:  begin
                             case Gear^.Frame div 10 of
-                                0:Tint(0, $FF, 0, floor(Gear^.FrameTicks * $FF / 1000));
-                                1:Tint($FF, 0, 0, floor(Gear^.FrameTicks * $FF / 1000));
+                                0:Tint(0, $FF, 0, round(Gear^.FrameTicks * $FF / 1000));
+                                1:Tint($FF, 0, 0, round(Gear^.FrameTicks * $FF / 1000));
                             end;
                             DrawSprite(sprHealth, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, 0);
                             end;
@@ -455,7 +455,7 @@
                             DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
                             end;
                 vgtSmokeRing: begin
-                            Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
+                            Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
                             end;
                 vgtChunk: DrawRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);