hedgewars/uVisualGears.pas
changeset 1045 ea195268734f
parent 1041 362b95d49cf4
child 1046 c22d833c3ae2
--- a/hedgewars/uVisualGears.pas	Tue Jul 01 22:26:36 2008 +0000
+++ b/hedgewars/uVisualGears.pas	Fri Jul 04 14:40:52 2008 +0000
@@ -40,7 +40,7 @@
 
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
 procedure ProcessVisualGears(Steps: Longword);
-procedure DrawVisualGears();
+procedure DrawVisualGears(Layer: LongWord);
 procedure DeleteVisualGear(Gear: PVisualGear);
 procedure AddClouds;
 
@@ -50,6 +50,7 @@
 
 implementation
 uses uWorld, uMisc, uStore;
+const cExplFrameTicks = 80;
 
 // ==================================================================
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
@@ -93,8 +94,14 @@
 Gear^.Y:= Gear^.Y + Gear^.dY;
 Gear^.dY:= Gear^.dY + cGravity;
 
-dec(Gear^.FrameTicks);
-if Gear^.FrameTicks = 0 then DeleteVisualGear(Gear)
+if Gear^.FrameTicks <= Steps then
+	if Gear^.Frame = 0 then DeleteVisualGear(Gear)
+	else
+		begin
+		dec(Gear^.Frame);
+		Gear^.FrameTicks:= cExplFrameTicks
+		end
+	else dec(Gear^.FrameTicks, Steps)
 end;
 
 // ==================================================================
@@ -107,6 +114,8 @@
 
 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
 var Result: PVisualGear;
+	t: Longword;
+	sp: hwFloat;
 begin
 New(Result);
 FillChar(Result^, sizeof(TVisualGear), 0);
@@ -138,11 +147,14 @@
                end;
   vgtExplPart: with Result^ do
                begin
+               t:= random(1024);
+               sp:= _0_001 * (random(700) + 150);
+               dx:= AngleSin(t) * sp;
                dx.isNegative:= random(2) = 0;
-               dx.QWordValue:= random(300000) + 1000000;
+               dy:= AngleCos(t) * sp;
                dy.isNegative:= random(2) = 0;
-               dy.QWordValue:= random(300000) + 1000000;
-               FrameTicks:= 700
+               Frame:= 7 - random(3);
+               FrameTicks:= cExplFrameTicks
                end;
      end;
 
@@ -179,22 +191,30 @@
       end
 end;
 
-procedure DrawVisualGears();
+procedure DrawVisualGears(Layer: LongWord);
 var Gear: PVisualGear;
 begin
 Gear:= VisualGearsList;
-while Gear <> nil do
-      begin
-      case Gear^.Kind of
-           vgtFlake: if vobVelocity = 0 then
-                        DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame)
-                     else
-                        DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-
-           vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame);
-              end;
-      Gear:= Gear^.NextGear
-      end;
+case Layer of
+	0: while Gear <> nil do
+		begin
+		case Gear^.Kind of
+			vgtFlake: if vobVelocity = 0 then
+						DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame)
+					else
+						DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+			vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame);
+			end;
+		Gear:= Gear^.NextGear
+		end;
+	1: while Gear <> nil do
+		begin
+		case Gear^.Kind of
+			vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
+			end;
+		Gear:= Gear^.NextGear
+		end
+	end
 end;
 
 procedure AddClouds;