Spread flakes out over 5 layers now (far back, mid distance, just behind land, just in front of lands and hog, near distance). Spread clouds out over 3 layers (far back, mid distance, just behind land). Add a flatten clouds option, use
authornemo
Sun, 06 Nov 2011 12:40:35 -0500
changeset 6302 db8bdbb34e03
parent 6301 1259736c0134
child 6303 3edb3c857995
Spread flakes out over 5 layers now (far back, mid distance, just behind land, just in front of lands and hog, near distance). Spread clouds out over 3 layers (far back, mid distance, just behind land). Add a flatten clouds option, use d on Underwater. Alter some flake PNGs to reduce variation in size since scaling is being used.
hedgewars/VGSHandlers.inc
hedgewars/uLandObjects.pas
hedgewars/uVariables.pas
hedgewars/uVisualGears.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Graphics/SuddenDeath/SDFlake.png
share/hedgewars/Data/Themes/Castle/Flake.png
share/hedgewars/Data/Themes/Christmas/Flake.png
share/hedgewars/Data/Themes/Golf/Flake.png
share/hedgewars/Data/Themes/Nature/Flake.png
share/hedgewars/Data/Themes/Snow/Flake.png
share/hedgewars/Data/Themes/Underwater/theme.cfg
--- a/hedgewars/VGSHandlers.inc	Sun Nov 06 17:43:57 2011 +0100
+++ b/hedgewars/VGSHandlers.inc	Sun Nov 06 12:40:35 2011 -0500
@@ -79,8 +79,8 @@
         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 + 25.0; // For if flag is set for flakes rising upwards?
-        if (Gear^.Layer > 1) and (round(Y) - 225 > LAND_HEIGHT) then Y:= Y - (1024 + 300) // TODO - configure in theme (jellies for example could use limited range)
-        else if (Gear^.Layer < 2) and (round(Y) + 50 > LAND_HEIGHT) then Y:= Y - (1024 + 25);
+        if (Gear^.Layer = 2) and (round(Y) - 225 > LAND_HEIGHT) then Y:= Y - (1024 + 300) // TODO - configure in theme (jellies for example could use limited range)
+        else if (Gear^.Layer <> 2) and (round(Y) + 50 > LAND_HEIGHT) then Y:= Y - (1024 + 25);
         Timer:= 0;
         tdX:= 0;
         tdY:= 0
--- a/hedgewars/uLandObjects.pas	Sun Nov 06 17:43:57 2011 +0100
+++ b/hedgewars/uLandObjects.pas	Sun Nov 06 12:40:35 2011 -0500
@@ -589,6 +589,7 @@
             end;
         end
     else if key = 'flatten-flakes' then cFlattenFlakes:= true
+    else if key = 'flatten-clouds' then cFlattenClouds:= true
     else if key = 'sd-water-top' then
         begin
         i:= Pos(',', s);
--- a/hedgewars/uVariables.pas	Sun Nov 06 17:43:57 2011 +0100
+++ b/hedgewars/uVariables.pas	Sun Nov 06 12:40:35 2011 -0500
@@ -47,6 +47,7 @@
     UserPathPrefix  : shortstring = './';
     cShowFPS        : boolean     = false;
     cFlattenFlakes  : boolean     = false;
+    cFlattenClouds  : boolean     = false;
     cAltDamage      : boolean     = true;
     cReducedQuality : LongWord    = rqNone;
     UserNick        : shortstring = '';
@@ -2334,7 +2335,7 @@
     framel, framer, depthl, depthr: GLuint;
     texl, texr: GLuint;
 
-    VisualGearLayers: array[0..3] of PVisualGear;
+    VisualGearLayers: array[0..6] of PVisualGear;
     lastVisualGearByUID: PVisualGear;
     vobFrameTicks, vobFramesCount, vobCount: Longword;
     vobVelocity, vobFallSpeed: LongInt;
@@ -2553,6 +2554,7 @@
     UserPathPrefix  := './';
     cShowFPS        := false;
     cFlattenFlakes  := false;
+    cFlattenClouds  := false;
     cAltDamage      := true;
     cReducedQuality := rqNone;
     UserNick        := '';
--- a/hedgewars/uVisualGears.pas	Sun Nov 06 17:43:57 2011 +0100
+++ b/hedgewars/uVisualGears.pas	Sun Nov 06 12:40:35 2011 -0500
@@ -338,14 +338,20 @@
 
 case Gear^.Kind of
     vgtFlake: if cFlattenFlakes then gear^.Layer:= 0
-              else if random(3) <> 0 then gear^.Layer:= 0   // 67%
-              else if random(3) <> 0 then gear^.Layer:= 1  // 22%
-              else gear^.Layer:= random(2)+2;  // 6% each
+              else if random(3) = 0 then gear^.Layer:= 0   // 33% - far back
+              else if random(3) = 0 then gear^.Layer:= 4   // 22% - mid-distance
+              else if random(2) = 0 then gear^.Layer:= 5   // 22% - just behind land
+              else if random(4) = 0 then gear^.Layer:= 6   // 15% - just in front of land
+              else gear^.Layer:= 2;  // 7% - close up
 
-    // 0: this layer is very distant in the background when stereo
+    vgtCloud: if cFlattenClouds then gear^.Layer:= 5
+              else if random(3) = 0 then gear^.Layer:= 0
+              else gear^.Layer:= random(2) + 4;
+
+    // 0: this layer is very distant in the background when in stereo
     vgtTeamHealthSorter,
-    vgtSmoothWindBar,
-    vgtCloud: gear^.Layer:= 0;
+    vgtSmoothWindBar: gear^.Layer:= 0;
+
 
     // 1: this layer is on the land level (which is close but behind the screen plane) when stereo
     vgtSmokeTrace,
@@ -414,7 +420,7 @@
 begin
 if Steps = 0 then exit;
 
-for i:= 0 to 3 do
+for i:= 0 to 6 do
     begin
     t:= VisualGearLayers[i];
     while t <> nil do
@@ -428,7 +434,7 @@
 
 procedure KickFlakes(Radius, X, Y: LongInt);
 var Gear, t: PVisualGear;
-    dmg: LongInt;
+    dmg, i: LongInt;
 begin
 if (vobCount = 0) or (vobCount > 200) then exit;
 t:= VisualGearLayers[1];
@@ -450,25 +456,28 @@
           end;
       t:= Gear^.NextGear
       end;
-t:= VisualGearLayers[3];
-while t <> nil do
-      begin
-      Gear:= t;
-      if Gear^.Kind = vgtFlake then
+for i:= 3 to 6 do
+    begin
+    t:= VisualGearLayers[i];
+    while t <> nil do
           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);
-          if dmg > 1 then
+          Gear:= t;
+          if Gear^.Kind = vgtFlake then
               begin
-              Gear^.tdX:= 0.02 * dmg + 0.01;
-              if Gear^.X - X < 0 then Gear^.tdX := -Gear^.tdX;
-              Gear^.tdY:= 0.02 * dmg + 0.01;
-              if Gear^.Y - Y < 0 then Gear^.tdY := -Gear^.tdY;
-              Gear^.Timer:= 200
-              end
-          end;
-      t:= Gear^.NextGear
-      end
+              // Damage calc from doMakeExplosion
+              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;
+                  if Gear^.X - X < 0 then Gear^.tdX := -Gear^.tdX;
+                  Gear^.tdY:= 0.02 * dmg + 0.01;
+                  if Gear^.Y - Y < 0 then Gear^.tdY := -Gear^.tdY;
+                  Gear^.Timer:= 200
+                  end
+              end;
+          t:= Gear^.NextGear
+          end
+     end
 end;
 
 procedure DrawVisualGears(Layer: LongWord);
@@ -485,6 +494,10 @@
            begin
            if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
            case Gear^.Kind of
+              vgtCloud: if SuddenDeathDmg then
+                             DrawTextureF(SpritesData[sprSDCloud].Texture, 0.5, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height)
+                         else
+                            DrawTextureF(SpritesData[sprCloud].Texture, 0.5, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height);
                vgtFlake: if cFlattenFlakes then
                              begin
                              if SuddenDeathDmg then
@@ -511,10 +524,6 @@
                                  else
                                      DrawRotatedTextureF(SpritesData[sprFlake].Texture, 0.5, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle)
                              end;
-               vgtCloud: if SuddenDeathDmg then
-                             DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
-                         else
-                             DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
                end;
            if Gear^.Tint <> $FFFFFFFF then Tint($FF,$FF,$FF,$FF);
            Gear:= Gear^.NextGear
@@ -577,6 +586,7 @@
            tinted:= false;
            if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
            case Gear^.Kind of
+(*
               vgtFlake: if SuddenDeathDmg then
                              if vobSDVelocity = 0 then
                                  DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
@@ -586,7 +596,7 @@
                              if vobVelocity = 0 then
                                  DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
                              else
-                                 DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
+                                 DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);*)
                vgtSpeechBubble: begin
                                 if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then
                                     begin
@@ -703,7 +713,81 @@
            if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
            Gear:= Gear^.NextGear
            end
-       end
+       end;
+    // this layer is half-way between the screen plane (depth = 0) when in stereo, and the land
+    4: begin
+       Gear:= VisualGearLayers[4];
+       while Gear <> nil do
+           begin
+           if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
+           case Gear^.Kind of
+              vgtCloud: if SuddenDeathDmg then
+                             DrawTextureF(SpritesData[sprSDCloud].Texture, 0.8, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height)
+                         else
+                            DrawTextureF(SpritesData[sprCloud].Texture, 0.8, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height);
+              vgtFlake: if SuddenDeathDmg then
+                             if vobSDVelocity = 0 then
+                                 DrawTextureF(SpritesData[sprSDFlake].Texture, 0.8, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height)
+                             else
+                                 DrawRotatedTextureF(SpritesData[sprSDFlake].Texture, 0.8, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle)
+                         else
+                             if vobVelocity = 0 then
+                                 DrawTextureF(SpritesData[sprFlake].Texture, 0.8, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height)
+                             else
+                                 DrawRotatedTextureF(SpritesData[sprFlake].Texture, 0.8, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle);
+               end;
+           if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF);
+           Gear:= Gear^.NextGear
+           end
+       end;
+    // this layer is on the screen plane (depth = 0) when stereo, but just behind the land
+    5: begin
+       Gear:= VisualGearLayers[5];
+       while Gear <> nil do
+           begin
+           if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
+           case Gear^.Kind of
+               vgtCloud: if SuddenDeathDmg then
+                             DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                         else
+                             DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
+              vgtFlake: if SuddenDeathDmg then
+                             if vobSDVelocity = 0 then
+                                 DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                             else
+                                 DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
+                         else
+                             if vobVelocity = 0 then
+                                 DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                             else
+                                 DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
+               end;
+           if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF);
+           Gear:= Gear^.NextGear
+           end
+       end;
+    // this layer is on the screen plane (depth = 0) when stereo, but just in front of the land
+    6: begin
+       Gear:= VisualGearLayers[6];
+       while Gear <> nil do
+           begin
+           if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
+           case Gear^.Kind of
+              vgtFlake: if SuddenDeathDmg then
+                             if vobSDVelocity = 0 then
+                                 DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                             else
+                                 DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
+                         else
+                             if vobVelocity = 0 then
+                                 DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                             else
+                                 DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
+               end;
+           if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF);
+           Gear:= Gear^.NextGear
+           end
+       end;
     end;
 end;
 
@@ -779,7 +863,7 @@
 begin
 if (cReducedQuality and rqKillFlakes) <> 0 then exit;
 if vobCount = vobSDCount then exit;
-for i:= 0 to 3 do
+for i:= 0 to 6 do
     begin
     vg:= VisualGearLayers[i];
     while vg <> nil do
@@ -802,14 +886,14 @@
 procedure initModule;
 var i: LongWord;
 begin
-for i:= 0 to 3 do
+for i:= 0 to 6 do
     VisualGearLayers[i]:= nil;
 end;
 
 procedure freeModule;
 var i: LongWord;
 begin
-for i:= 0 to 3 do
+for i:= 0 to 6 do
     while VisualGearLayers[i] <> nil do DeleteVisualGear(VisualGearLayers[i]);
 end;
 
--- a/hedgewars/uWorld.pas	Sun Nov 06 17:43:57 2011 +0100
+++ b/hedgewars/uWorld.pas	Sun Nov 06 12:40:35 2011 -0500
@@ -74,6 +74,7 @@
 
 const cStereo_Sky           = 0.0500;
       cStereo_Horizon       = 0.0250;
+      cStereo_MidDistance   = 0.0175;
       cStereo_Water_distant = 0.0125;
       cStereo_Land          = 0.0075;
       cStereo_Water_near    = 0.0025;
@@ -799,6 +800,8 @@
     end;
 
     DrawVisualGears(0);
+    ChangeDepth(RM, -cStereo_MidDistance);
+    DrawVisualGears(4);
 
     if (cReducedQuality and rq2DWater) = 0 then
     begin
@@ -817,6 +820,7 @@
         DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
 
     changeDepth(RM, cStereo_Land);
+    DrawVisualGears(5);
     DrawLand(WorldDx, WorldDy);
 
     DrawWater(255, 0);
@@ -845,6 +849,7 @@
 
     DrawVisualGears(1);
     DrawGears;
+    DrawVisualGears(6);
 
     if SuddenDeathDmg then
         DrawWater(cSDWaterOpacity, 0)
Binary file share/hedgewars/Data/Graphics/SuddenDeath/SDFlake.png has changed
Binary file share/hedgewars/Data/Themes/Castle/Flake.png has changed
Binary file share/hedgewars/Data/Themes/Christmas/Flake.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Flake.png has changed
Binary file share/hedgewars/Data/Themes/Nature/Flake.png has changed
Binary file share/hedgewars/Data/Themes/Snow/Flake.png has changed
--- a/share/hedgewars/Data/Themes/Underwater/theme.cfg	Sun Nov 06 17:43:57 2011 +0100
+++ b/share/hedgewars/Data/Themes/Underwater/theme.cfg	Sun Nov 06 12:40:35 2011 -0500
@@ -5,6 +5,7 @@
 water-opacity = $FF
 music = underwater.ogg
 clouds = 9
+flatten-clouds = yes
 object = anchor, 3, 65, 258, 80, 2, 1, 0, 0, 240, 215
 object = clam, 3, 60, 131, 16, 2, 1, 0, 0, 150, 117
 object = crab, 3, 78, 256, 96, 2, 1, 3, 60, 237, 155