hedgewars/uVisualGears.pas
branchwebgl
changeset 8330 aaefa587e277
parent 8026 4a4f21070479
parent 8204 9a6030d96273
child 8444 75db7bb8dce8
equal deleted inserted replaced
8116:d24257910f8d 8330:aaefa587e277
    51 procedure ChangeToSDFlakes;
    51 procedure ChangeToSDFlakes;
    52 
    52 
    53 procedure KickFlakes(Radius, X, Y: LongInt);
    53 procedure KickFlakes(Radius, X, Y: LongInt);
    54 
    54 
    55 implementation
    55 implementation
    56 uses uSound, uMobile, uVariables, uTextures, uRender, Math, uRenderUtils, uStore, uUtils;
    56 uses uSound, uVariables, uTextures, uRender, Math, uRenderUtils, uStore, uUtils;
    57 
    57 
    58 const cExplFrameTicks = 110;
    58 const
       
    59     cExplFrameTicks = 110;
       
    60     cSmokeZ = 499;
    59 var VGCounter: LongWord;
    61 var VGCounter: LongWord;
       
    62     VisualGearLayers: array[0..6] of PVisualGear;
    60 
    63 
    61 // For better maintainability the step handlers of visual gears are stored
    64 // For better maintainability the step handlers of visual gears are stored
    62 // in a separate file.
    65 // in a separate file.
    63 {$INCLUDE "VGSHandlers.inc"}
    66 {$INCLUDE "VGSHandlers.inc"}
    64 
    67 
   149     vgtExplosion,
   152     vgtExplosion,
   150     vgtSmokeTrace,
   153     vgtSmokeTrace,
   151     vgtEvilTrace,
   154     vgtEvilTrace,
   152     vgtNote,
   155     vgtNote,
   153     vgtSmoothWindBar])) then
   156     vgtSmoothWindBar])) then
   154     
   157 
   155         exit;
   158         exit;
   156 
   159 
   157 inc(VGCounter);
   160 inc(VGCounter);
   158 New(gear);
   161 New(gear);
   159 FillChar(gear^, sizeof(TVisualGear), 0);
   162 FillChar(gear^, sizeof(TVisualGear), 0);
   363                 dx:= hwFloat2Float(AngleSin(t)) * sp;
   366                 dx:= hwFloat2Float(AngleSin(t)) * sp;
   364                 dy:= hwFloat2Float(AngleCos(t)) * sp * -2;
   367                 dy:= hwFloat2Float(AngleCos(t)) * sp * -2;
   365                 if random(2) = 0 then
   368                 if random(2) = 0 then
   366                     dx := -dx;
   369                     dx := -dx;
   367                 end;
   370                 end;
   368       vgtNote: 
   371       vgtNote:
   369                 begin
   372                 begin
   370                 dx:= 0.005 * (random(15) + 10);
   373                 dx:= 0.005 * (random(15) + 10);
   371                 dy:= -0.001 * (random(40) + 20);
   374                 dy:= -0.001 * (random(40) + 20);
   372                 if random(2) = 0 then
   375                 if random(2) = 0 then
   373                     dx := -dx;
   376                     dx := -dx;
   380                 dy:= 0;
   383                 dy:= 0;
   381                 FrameTicks:= 350;
   384                 FrameTicks:= 350;
   382                 Frame:= 7;
   385                 Frame:= 7;
   383                 Angle:= 0;
   386                 Angle:= 0;
   384                 end;
   387                 end;
   385 vgtSmoothWindBar: 
   388 vgtSmoothWindBar:
   386                 begin
   389                 begin
   387                 Angle:= hwFloat2Float(cMaxWindSpeed)*2 / 1440; // seems rate below is supposed to change wind bar at 1px per 10ms. Max time, 1440ms. This tries to match the rate of change
   390                 Angle:= hwFloat2Float(cMaxWindSpeed)*2 / 1440; // seems rate below is supposed to change wind bar at 1px per 10ms. Max time, 1440ms. This tries to match the rate of change
   388                 Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
   391                 Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
   389                 end;
   392                 end;
   390  vgtStraightShot:
   393  vgtStraightShot:
   406     gear^.State:= State;
   409     gear^.State:= State;
   407 
   410 
   408 case Gear^.Kind of
   411 case Gear^.Kind of
   409     vgtFlake: if cFlattenFlakes then
   412     vgtFlake: if cFlattenFlakes then
   410         gear^.Layer:= 0
   413         gear^.Layer:= 0
   411               else if random(3) = 0 then 
   414               else if random(3) = 0 then
   412                   begin
   415                   begin
   413                   gear^.Scale:= 0.5;
   416                   gear^.Scale:= 0.5;
   414                   gear^.Layer:= 0   // 33% - far back
   417                   gear^.Layer:= 0   // 33% - far back
   415                   end
   418                   end
   416               else if random(3) = 0 then
   419               else if random(3) = 0 then
   697                                     end
   700                                     end
   698                                 else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team = CurrentTeam)) or (Gear^.State = 2)) then
   701                                 else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team = CurrentTeam)) or (Gear^.State = 2)) then
   699                                     DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   702                                     DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   700                                 end;
   703                                 end;
   701                vgtSmallDamageTag: DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   704                vgtSmallDamageTag: DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   702                vgtHealthTag: if Gear^.Tex <> nil then 
   705                vgtHealthTag: if Gear^.Tex <> nil then
   703                                begin
   706                                begin
   704                                if Gear^.Frame = 0 then 
   707                                if Gear^.Frame = 0 then
   705                                    DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
   708                                    DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
   706                                else
   709                                else
   707                                    begin
   710                                    begin
   708                                    SetScale(cDefaultZoomLevel);
   711                                    SetScale(cDefaultZoomLevel);
   709                                    if Gear^.Angle = 0 then
   712                                    if Gear^.Angle = 0 then
   710                                        DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex)
   713                                        DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex)
   711                                    else
   714                                    else
   712                                        DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex, Gear^.Angle); 
   715                                        DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex, Gear^.Angle);
   713                                    SetScale(zoom)
   716                                    SetScale(zoom)
   714                                    end
   717                                    end
   715                                end;
   718                                end;
   716                vgtStraightShot: begin 
   719                vgtStraightShot: begin
   717                                 if Gear^.dX < 0 then
   720                                 if Gear^.dX < 0 then
   718                                     i:= -1
   721                                     i:= -1
   719                                 else
   722                                 else
   720                                     i:= 1;
   723                                     i:= 1;
   721                                 DrawTextureRotatedF(SpritesData[TSprite(Gear^.State)].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, i, SpritesData[TSprite(Gear^.State)].Width, SpritesData[TSprite(Gear^.State)].Height, Gear^.Angle);
   724                                 DrawTextureRotatedF(SpritesData[TSprite(Gear^.State)].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, i, SpritesData[TSprite(Gear^.State)].Width, SpritesData[TSprite(Gear^.State)].Height, Gear^.Angle);