hedgewars/uVisualGears.pas
changeset 1046 c22d833c3ae2
parent 1045 ea195268734f
child 1047 ca7078116c0c
equal deleted inserted replaced
1045:ea195268734f 1046:c22d833c3ae2
    87 if hwRound(Gear^.X) > cScreenWidth + 2048 then Gear^.X:= int2hwFloat(-cScreenWidth - 256)
    87 if hwRound(Gear^.X) > cScreenWidth + 2048 then Gear^.X:= int2hwFloat(-cScreenWidth - 256)
    88 end;
    88 end;
    89 
    89 
    90 procedure doStepExpl(Gear: PVisualGear; Steps: Longword);
    90 procedure doStepExpl(Gear: PVisualGear; Steps: Longword);
    91 begin
    91 begin
    92 Gear^.X:= Gear^.X + Gear^.dX;
    92 Gear^.X:= Gear^.X + Gear^.dX * Steps;
    93 
    93 
    94 Gear^.Y:= Gear^.Y + Gear^.dY;
    94 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
    95 Gear^.dY:= Gear^.dY + cGravity;
    95 //Gear^.dY:= Gear^.dY + cGravity;
    96 
    96 
    97 if Gear^.FrameTicks <= Steps then
    97 if Gear^.FrameTicks <= Steps then
    98 	if Gear^.Frame = 0 then DeleteVisualGear(Gear)
    98 	if Gear^.Frame = 0 then DeleteVisualGear(Gear)
    99 	else
    99 	else
   100 		begin
   100 		begin
   102 		Gear^.FrameTicks:= cExplFrameTicks
   102 		Gear^.FrameTicks:= cExplFrameTicks
   103 		end
   103 		end
   104 	else dec(Gear^.FrameTicks, Steps)
   104 	else dec(Gear^.FrameTicks, Steps)
   105 end;
   105 end;
   106 
   106 
       
   107 procedure doStepFire(Gear: PVisualGear; Steps: Longword);
       
   108 begin
       
   109 Gear^.X:= Gear^.X + Gear^.dX * Steps;
       
   110 
       
   111 Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravity * (Steps * Steps);
       
   112 Gear^.dY:= Gear^.dY + cGravity * Steps;
       
   113 
       
   114 if Gear^.FrameTicks <= Steps then
       
   115 	DeleteVisualGear(Gear)
       
   116 else
       
   117 	dec(Gear^.FrameTicks, Steps)
       
   118 end;
       
   119 
   107 // ==================================================================
   120 // ==================================================================
   108 const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
   121 const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
   109                         (
   122                         (
   110                           @doStepFlake,
   123                           @doStepFlake,
   111                           @doStepCloud,
   124                           @doStepCloud,
   112                           @doStepExpl
   125                           @doStepExpl,
       
   126                           @doStepFire
   113                         );
   127                         );
   114 
   128 
   115 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   129 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   116 var Result: PVisualGear;
   130 var Result: PVisualGear;
   117 	t: Longword;
   131 	t: Longword;
   146                mdY:= dy.QWordValue
   160                mdY:= dy.QWordValue
   147                end;
   161                end;
   148   vgtExplPart: with Result^ do
   162   vgtExplPart: with Result^ do
   149                begin
   163                begin
   150                t:= random(1024);
   164                t:= random(1024);
   151                sp:= _0_001 * (random(700) + 150);
   165                sp:= _0_001 * (random(80) + 85);
   152                dx:= AngleSin(t) * sp;
   166                dx:= AngleSin(t) * sp;
   153                dx.isNegative:= random(2) = 0;
   167                dx.isNegative:= random(2) = 0;
   154                dy:= AngleCos(t) * sp;
   168                dy:= AngleCos(t) * sp;
   155                dy.isNegative:= random(2) = 0;
   169                dy.isNegative:= random(2) = 0;
   156                Frame:= 7 - random(3);
   170                Frame:= 7 - random(3);
   157                FrameTicks:= cExplFrameTicks
   171                FrameTicks:= cExplFrameTicks
       
   172                end;
       
   173       vgtFire: with Result^ do
       
   174                begin
       
   175                t:= random(1024);
       
   176                sp:= _0_001 * (random(85) + 95);
       
   177                dx:= AngleSin(t) * sp;
       
   178                dx.isNegative:= random(2) = 0;
       
   179                dy:= AngleCos(t) * sp;
       
   180                dy.isNegative:= random(2) = 0;
       
   181                FrameTicks:= 400 + random(200);
       
   182                Frame:= random(8)
   158                end;
   183                end;
   159      end;
   184      end;
   160 
   185 
   161 if VisualGearsList <> nil then
   186 if VisualGearsList <> nil then
   162    begin
   187    begin
   209 		end;
   234 		end;
   210 	1: while Gear <> nil do
   235 	1: while Gear <> nil do
   211 		begin
   236 		begin
   212 		case Gear^.Kind of
   237 		case Gear^.Kind of
   213 			vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
   238 			vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
       
   239 			vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
   214 			end;
   240 			end;
   215 		Gear:= Gear^.NextGear
   241 		Gear:= Gear^.NextGear
   216 		end
   242 		end
   217 	end
   243 	end
   218 end;
   244 end;