Fade out rising flakes at the top
authorWuzzy <Wuzzy2@mail.ru>
Wed, 27 May 2020 00:00:13 +0200
changeset 15605 e1078c72ad60
parent 15604 6a38a30e772a
child 15606 b2b72fc7fc14
Fade out rising flakes at the top
ChangeLog.txt
hedgewars/uVisualGearsHandlers.pas
--- a/ChangeLog.txt	Tue May 26 23:02:49 2020 +0200
+++ b/ChangeLog.txt	Wed May 27 00:00:13 2020 +0200
@@ -7,6 +7,7 @@
  + Racer: Reset mines, air mines and sticky mines every turn
  + A Space Adventure: Spacetrip: Meteorite appears blown-up after victory
  + New flags: serbia, montenegro
+ + Themes: Rising flakes fade out at the top
  * Racer: Resize waypoints in custom-sized drawn maps
  * Mutant: Fix impossible to become mutant after mutant is gone
  * A Classic Fairytale: Mission 1: Fix possibility of getting stuck in “Leap of Faith” section
--- a/hedgewars/uVisualGearsHandlers.pas	Tue May 26 23:02:49 2020 +0200
+++ b/hedgewars/uVisualGearsHandlers.pas	Wed May 27 00:00:13 2020 +0200
@@ -80,7 +80,7 @@
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
 var sign: real;
     moved, rising, outside: boolean;
-    vfc, vft: LongWord;
+    vfc, vft, diff: LongWord;
     spawnMargin: LongInt;
 const
     randMargin = 50;
@@ -180,17 +180,40 @@
         // flake fell far below map?
         outside:= (not rising) and (round(Y) - spawnMargin + randMargin > LAND_HEIGHT);
         // if not, did it rise far above map?
-        outside:= outside or (rising and (round(Y) < LAND_HEIGHT - 1024 - spawnMargin - randMargin));
+        outside:= outside or (rising and (round(Y) < LAND_HEIGHT - 1024 - randMargin));
 
         // if flake left acceptable vertical area, respawn it opposite side
         if outside then
             begin
-            X:= cLeftScreenBorder + random(cScreenSpace);
             if rising then
-                Y:= Y + (1024 + spawnMargin + random(50))
+                begin
+                if State = 0 then
+                    begin
+                    // fade out rising flake
+                    diff:= (LAND_HEIGHT - 1024 - randMargin) - round(Y);
+                    diff:= Min(diff*2, $FF);
+                    if diff >= $FF then
+                        begin
+                        diff:= $FF;
+                        State:= 1;
+                        end;
+                    Tint:= (Tint and $FFFFFF00) or ($FF - diff);
+                    end
+                else
+                    begin
+                    Y:= LAND_HEIGHT + spawnMargin + random(50);
+                    moved:= true;
+                    State:= 0;
+                    Tint:= Tint or $FF;
+                    end;
+                end
             else
+                begin
                 Y:= Y - (1024 + spawnMargin + random(50));
-            moved:= true;
+                moved:= true;
+                end;
+            if moved then
+                X:= cLeftScreenBorder + random(cScreenSpace);
             end;
 
         if moved then