hedgewars/uVisualGears.pas
changeset 1047 ca7078116c0c
parent 1046 c22d833c3ae2
child 1066 1f1b3686a2b0
equal deleted inserted replaced
1046:c22d833c3ae2 1047:ca7078116c0c
    48     vobFrameTicks, vobFramesCount: Longword;
    48     vobFrameTicks, vobFramesCount: Longword;
    49     vobVelocity, vobFallSpeed: LongInt;
    49     vobVelocity, vobFallSpeed: LongInt;
    50 
    50 
    51 implementation
    51 implementation
    52 uses uWorld, uMisc, uStore;
    52 uses uWorld, uMisc, uStore;
    53 const cExplFrameTicks = 80;
    53 const cExplFrameTicks = 110;
    54 
    54 
    55 // ==================================================================
    55 // ==================================================================
    56 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
    56 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
    57 begin
    57 begin
    58 with Gear^ do
    58 with Gear^ do
   121 const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
   121 const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure =
   122                         (
   122                         (
   123                           @doStepFlake,
   123                           @doStepFlake,
   124                           @doStepCloud,
   124                           @doStepCloud,
   125                           @doStepExpl,
   125                           @doStepExpl,
       
   126                           @doStepExpl,
   126                           @doStepFire
   127                           @doStepFire
   127                         );
   128                         );
   128 
   129 
   129 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   130 function  AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear;
   130 var Result: PVisualGear;
   131 var Result: PVisualGear;
   157                dx.QWordValue:= random(214748364);
   158                dx.QWordValue:= random(214748364);
   158                dy.isNegative:= random(2) = 0;
   159                dy.isNegative:= random(2) = 0;
   159                dy.QWordValue:= 21474836 + random(64424509);
   160                dy.QWordValue:= 21474836 + random(64424509);
   160                mdY:= dy.QWordValue
   161                mdY:= dy.QWordValue
   161                end;
   162                end;
   162   vgtExplPart: with Result^ do
   163   vgtExplPart,
       
   164  vgtExplPart2: with Result^ do
   163                begin
   165                begin
   164                t:= random(1024);
   166                t:= random(1024);
   165                sp:= _0_001 * (random(80) + 85);
   167                sp:= _0_001 * (random(95) + 70);
   166                dx:= AngleSin(t) * sp;
   168                dx:= AngleSin(t) * sp;
   167                dx.isNegative:= random(2) = 0;
   169                dx.isNegative:= random(2) = 0;
   168                dy:= AngleCos(t) * sp;
   170                dy:= AngleCos(t) * sp;
   169                dy.isNegative:= random(2) = 0;
   171                dy.isNegative:= random(2) = 0;
   170                Frame:= 7 - random(3);
   172                Frame:= 7 - random(3);
   176                sp:= _0_001 * (random(85) + 95);
   178                sp:= _0_001 * (random(85) + 95);
   177                dx:= AngleSin(t) * sp;
   179                dx:= AngleSin(t) * sp;
   178                dx.isNegative:= random(2) = 0;
   180                dx.isNegative:= random(2) = 0;
   179                dy:= AngleCos(t) * sp;
   181                dy:= AngleCos(t) * sp;
   180                dy.isNegative:= random(2) = 0;
   182                dy.isNegative:= random(2) = 0;
   181                FrameTicks:= 400 + random(200);
   183                FrameTicks:= 650 + random(250);
   182                Frame:= random(8)
   184                Frame:= random(8)
   183                end;
   185                end;
   184      end;
   186      end;
   185 
   187 
   186 if VisualGearsList <> nil then
   188 if VisualGearsList <> nil then
   234 		end;
   236 		end;
   235 	1: while Gear <> nil do
   237 	1: while Gear <> nil do
   236 		begin
   238 		begin
   237 		case Gear^.Kind of
   239 		case Gear^.Kind of
   238 			vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
   240 			vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame);
       
   241 			vgtExplPart2: DrawSprite(sprExplPart2, 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);
   242 			vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
   240 			end;
   243 			end;
   241 		Gear:= Gear^.NextGear
   244 		Gear:= Gear^.NextGear
   242 		end
   245 		end
   243 	end
   246 	end