hedgewars/uVisualGears.pas
changeset 803 3f73901a350a
parent 802 ed5450a89b96
child 805 4d75759b38bd
--- a/hedgewars/uVisualGears.pas	Fri Mar 07 17:43:05 2008 +0000
+++ b/hedgewars/uVisualGears.pas	Fri Mar 07 18:10:03 2008 +0000
@@ -38,22 +38,33 @@
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; dX, dY: hwFloat): PVisualGear;
 procedure ProcessVisualGears(Steps: Longword);
 procedure DrawVisualGears();
-//procedure AddClouds;
+procedure AddClouds;
 
 var VisualGearsList: PVisualGear = nil;
 
 implementation
-uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
-     uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers, GL;
+uses uWorld, uMisc, uStore, GL;
 
+// ==================================================================
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
 begin
 end;
 
-// =============
+procedure doStepCloud(Gear: PVisualGear; Steps: Longword);
+begin
+Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps;
+if hwRound(Gear^.Y) > -160 then Gear^.dY:= Gear^.dY - _1div50000
+                           else Gear^.dY:= Gear^.dY + _1div50000;
+Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
+if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + 2048) else
+if hwRound(Gear^.X) > cScreenWidth + 2048 then Gear^.X:= int2hwFloat(-cScreenWidth - 256)
+end;
+
+// ==================================================================
 const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
                         (
-                          @doStepFlake
+                          @doStepFlake,
+                          @doStepCloud
                         );
 
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; dX, dY: hwFloat): PVisualGear;
@@ -68,6 +79,10 @@
 Result^.dY:= dY;
 Result^.doStep:= doStepHandlers[Kind];
 
+case Kind of
+   vgtCloud: Result^.State:= random(4);
+     end;
+
 if VisualGearsList <> nil then
    begin
    VisualGearsList^.PrevGear:= Result;
@@ -82,6 +97,8 @@
 procedure ProcessVisualGears(Steps: Longword);
 var Gear, t: PVisualGear;
 begin
+if Steps = 0 then exit;
+
 t:= VisualGearsList;
 while t <> nil do
       begin
@@ -98,8 +115,8 @@
 while Gear <> nil do
       begin
       case Gear^.Kind of
-//           gtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, nil);
            vgtFlake: ;
+           vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, nil);
               end;
       Gear:= Gear^.NextGear
       end;
@@ -108,7 +125,7 @@
 procedure AddClouds;
 var i: LongInt;
     dx, dy: hwFloat;
-begin(*
+begin
 for i:= 0 to cCloudsNumber do
     begin
     dx.isNegative:= random(2) = 1;
@@ -117,7 +134,7 @@
     dy.QWordValue:= 21474836 + random(64424509);
     AddVisualGear( - cScreenWidth + i * ((cScreenWidth * 2 + 2304) div cCloudsNumber), -140,
              vgtCloud, dx, dy)
-    end*)
+    end
 end;
 
 initialization