clouds: up-and-down-bouncing now without evil loop
authorsheepluva
Wed, 30 Jun 2010 03:26:15 +0200
changeset 3592 0bcad5c38c9e
parent 3591 c447d5218f6f
child 3593 ae50f63e4fa9
clouds: up-and-down-bouncing now without evil loop
hedgewars/VGSHandlers.inc
hedgewars/uVisualGears.pas
--- a/hedgewars/VGSHandlers.inc	Tue Jun 29 23:25:42 2010 +0200
+++ b/hedgewars/VGSHandlers.inc	Wed Jun 30 03:26:15 2010 +0200
@@ -70,19 +70,19 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepCloud(Gear: PVisualGear; Steps: Longword);
-var i: Longword;
+var s: Longword;
+    t: hwFloat;
 begin
 Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps;
 
-for i:= 0 to Steps - 1 do
-    begin
-    if hwRound(Gear^.Y) > LAND_HEIGHT-1184 then // TODO - configure in theme
-        Gear^.dY:= Gear^.dY - _1div50000
-    else
-        Gear^.dY:= Gear^.dY + _1div50000;
+// up-and-down-bounce magic
+s := (GameTicks + Gear^.mdy) mod 4096;
+t := AngleSin(s mod 2048);
+t.isNegative := (s < 2048);
+t.QWordValue := t.QWordValue * 8;
 
-    Gear^.Y:= Gear^.Y + Gear^.dY
-    end;
+Gear^.Y := int2hwFloat(LAND_HEIGHT-1184 + Gear^.mdy mod 8) + t;
+
 
 if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + LAND_WIDTH) else
 if hwRound(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= int2hwFloat(-cScreenWidth - 256)
--- a/hedgewars/uVisualGears.pas	Tue Jun 29 23:25:42 2010 +0200
+++ b/hedgewars/uVisualGears.pas	Wed Jun 30 03:26:15 2010 +0200
@@ -174,9 +174,7 @@
                 Frame:= random(4);
                 dx.isNegative:= random(2) = 0;
                 dx.QWordValue:= random(214748364);
-                dy.isNegative:= random(2) = 0;
-                dy.QWordValue:= 21474836 + random(64424509);
-                mdY:= dy.QWordValue
+                mdY:= random(4096);
                 end;
     vgtExplPart,
     vgtExplPart2: begin