hedgewars/uVisualGears.pas
changeset 13638 35d93b1e7fef
parent 13334 e8801220c13f
child 14577 34e810295d08
equal deleted inserted replaced
13637:4c49a4944884 13638:35d93b1e7fef
    33 
    33 
    34 procedure initModule;
    34 procedure initModule;
    35 procedure freeModule;
    35 procedure freeModule;
    36 
    36 
    37 procedure ProcessVisualGears(Steps: Longword);
    37 procedure ProcessVisualGears(Steps: Longword);
    38 procedure DrawVisualGears(Layer: LongWord);
    38 procedure DrawVisualGears(Layer: LongWord; worldIsShifted: boolean);
    39 
    39 
    40 procedure AddClouds;
    40 procedure AddClouds;
    41 procedure AddFlakes;
    41 procedure AddFlakes;
    42 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
    42 procedure AddDamageTag(X, Y, Damage, Color: LongWord);
    43 
    43 
   136 function GetSpriteData(sprite, SDsprite: TSprite): PSpriteData; inline;
   136 function GetSpriteData(sprite, SDsprite: TSprite): PSpriteData; inline;
   137 begin
   137 begin
   138     exit(@SpritesData[GetSprite(sprite, SDsprite)]);
   138     exit(@SpritesData[GetSprite(sprite, SDsprite)]);
   139 end;
   139 end;
   140 
   140 
   141 procedure DrawVisualGears(Layer: LongWord);
   141 procedure DrawVisualGears(Layer: LongWord; worldIsShifted: boolean);
   142 var Gear: PVisualGear;
   142 var Gear: PVisualGear;
   143     tinted, speedlessFlakes: boolean;
   143     tinted, speedlessFlakes: boolean;
   144     tmp: real;
   144     tmp: real;
   145     i: LongInt;
   145     i: LongInt;
   146     sprite: TSprite;
   146     sprite: TSprite;
   161             case Gear^.Kind of
   161             case Gear^.Kind of
   162               vgtCloud: begin
   162               vgtCloud: begin
   163                         spriteData:= GetSpriteData(GetSpriteByWind(sprCloud, sprCloudL), GetSpriteByWind(sprSDCloud, sprSDCloudL));
   163                         spriteData:= GetSpriteData(GetSpriteByWind(sprCloud, sprCloudL), GetSpriteByWind(sprSDCloud, sprSDCloudL));
   164                         DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height)
   164                         DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height)
   165                         end;
   165                         end;
   166                vgtFlake: begin
   166                vgtFlake: if (not worldIsShifted) then
   167                          sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
       
   168                          if cFlattenFlakes then
       
   169                              begin
   167                              begin
   170                              if speedlessFlakes then
   168                              sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
   171                                  DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   169                              if cFlattenFlakes then
       
   170                                  begin
       
   171                                  if speedlessFlakes then
       
   172                                      DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
       
   173                                  else
       
   174                                      DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
       
   175                                  end
   172                              else
   176                              else
   173                                  DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   177                                  begin
   174                              end
   178                                  if speedlessFlakes then
   175                          else
   179                                      DrawTextureF(SpritesData[sprite].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height)
   176                              begin
   180                                  else
   177                              if speedlessFlakes then
   181                                      DrawTextureRotatedF(SpritesData[sprite].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle);
   178                                  DrawTextureF(SpritesData[sprite].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height)
   182                                  end;
   179                              else
       
   180                                  DrawTextureRotatedF(SpritesData[sprite].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle);
       
   181                              end;
   183                              end;
   182                          end;
       
   183                end;
   184                end;
   184            if Gear^.Tint <> $FFFFFFFF then
   185            if Gear^.Tint <> $FFFFFFFF then
   185                untint;
   186                untint;
   186            Gear:= Gear^.NextGear
   187            Gear:= Gear^.NextGear
   187            end
   188            end
   193           begin
   194           begin
   194           //tinted:= false;
   195           //tinted:= false;
   195           if Gear^.Tint <> $FFFFFFFF then
   196           if Gear^.Tint <> $FFFFFFFF then
   196               Tint(Gear^.Tint);
   197               Tint(Gear^.Tint);
   197           case Gear^.Kind of
   198           case Gear^.Kind of
   198               vgtFlake: begin
   199               vgtFlake: if (not worldIsShifted) then
   199                          sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
   200                             begin
   200                          if speedlessFlakes then
   201                             sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
   201                              DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   202                             if speedlessFlakes then
   202                          else
   203                                 DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   203                              DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   204                             else
   204                         end;
   205                                 DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
       
   206                             end;
   205               vgtSmokeTrace: if Gear^.State < 8 then
   207               vgtSmokeTrace: if Gear^.State < 8 then
   206                   DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   208                   DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   207               vgtEvilTrace: if Gear^.State < 8 then
   209               vgtEvilTrace: if Gear^.State < 8 then
   208                   DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   210                   DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   209               vgtLineTrail: DrawLine(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 1.0, $FF, min(Gear^.Timer, $C0), min(Gear^.Timer, $80), min(Gear^.Timer, (Gear^.Tint and $FF)));
   211               vgtLineTrail: DrawLine(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 1.0, $FF, min(Gear^.Timer, $C0), min(Gear^.Timer, $80), min(Gear^.Timer, (Gear^.Tint and $FF)));
   366                                  end;
   368                                  end;
   367                    vgtNote: DrawSpriteRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   369                    vgtNote: DrawSpriteRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   368                    vgtBulletHit: DrawSpriteRotatedF(sprBulletHit, round(Gear^.X) + WorldDx - 0, round(Gear^.Y) + WorldDy - 0, 7 - (Gear^.FrameTicks div 50), 1, Gear^.Angle);
   370                    vgtBulletHit: DrawSpriteRotatedF(sprBulletHit, round(Gear^.X) + WorldDx - 0, round(Gear^.Y) + WorldDy - 0, 7 - (Gear^.FrameTicks div 50), 1, Gear^.Angle);
   369                end;
   371                end;
   370            case Gear^.Kind of
   372            case Gear^.Kind of
   371                vgtFlake: begin
   373                vgtFlake: if (not worldIsShifted) then
   372                          spriteData:= GetSpriteData(GetSpriteByWind(sprFlake, sprFlakeL), GetSpriteByWind(sprSDFlake, sprSDFlakeL));
   374                          begin
   373                          if speedlessFlakes then
   375                              spriteData:= GetSpriteData(GetSpriteByWind(sprFlake, sprFlakeL), GetSpriteByWind(sprSDFlake, sprSDFlakeL));
   374                              DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height)
   376                              if speedlessFlakes then
   375                          else
   377                                  DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height)
   376                              DrawTextureRotatedF(spriteData^.Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height, Gear^.Angle);
   378                              else
   377                          end;
   379                                  DrawTextureRotatedF(spriteData^.Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height, Gear^.Angle);
       
   380                              end;
   378                vgtCircle: if gear^.Angle = 1 then
   381                vgtCircle: if gear^.Angle = 1 then
   379                               begin
   382                               begin
   380                               tmp:= Gear^.State / 100;
   383                               tmp:= Gear^.State / 100;
   381                               DrawTexture(round(Gear^.X-24*tmp) + WorldDx, round(Gear^.Y-24*tmp) + WorldDy, SpritesData[sprVampiric].Texture, tmp)
   384                               DrawTexture(round(Gear^.X-24*tmp) + WorldDx, round(Gear^.Y-24*tmp) + WorldDy, SpritesData[sprVampiric].Texture, tmp)
   382                               end
   385                               end
   398             case Gear^.Kind of
   401             case Gear^.Kind of
   399                vgtCloud: begin
   402                vgtCloud: begin
   400                          spriteData:= GetSpriteData(GetSpriteByWind(sprCloud, sprCloudL), GetSpriteByWind(sprSDCloud, sprSDCloudL));
   403                          spriteData:= GetSpriteData(GetSpriteByWind(sprCloud, sprCloudL), GetSpriteByWind(sprSDCloud, sprSDCloudL));
   401                          DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height);
   404                          DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height);
   402                          end;
   405                          end;
   403               vgtFlake: begin
   406               vgtFlake: if (not worldIsShifted) then
   404                         spriteData:= GetSpriteData(GetSpriteByWind(sprFlake, sprFlakeL), GetSpriteByWind(sprSDFlake, sprSDFlakeL));
   407                             begin
   405                         if speedlessFlakes then
   408                             spriteData:= GetSpriteData(GetSpriteByWind(sprFlake, sprFlakeL), GetSpriteByWind(sprSDFlake, sprSDFlakeL));
   406                             DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height)
   409                             if speedlessFlakes then
   407                         else
   410                                 DrawTextureF(spriteData^.Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height)
   408                             DrawTextureRotatedF(spriteData^.Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height, Gear^.Angle);
   411                             else
   409                         end;
   412                                 DrawTextureRotatedF(spriteData^.Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, spriteData^.Width, spriteData^.Height, Gear^.Angle);
       
   413                             end;
   410             end;
   414             end;
   411             if (Gear^.Tint <> $FFFFFFFF) then
   415             if (Gear^.Tint <> $FFFFFFFF) then
   412                 untint;
   416                 untint;
   413             Gear:= Gear^.NextGear
   417             Gear:= Gear^.NextGear
   414             end
   418             end
   423             case Gear^.Kind of
   427             case Gear^.Kind of
   424                 vgtCloud: begin
   428                 vgtCloud: begin
   425                         sprite:= GetSpriteByWind(GetSprite(sprCloud, sprSDCloud), GetSprite(sprCloudL, sprSDCloudL));
   429                         sprite:= GetSpriteByWind(GetSprite(sprCloud, sprSDCloud), GetSprite(sprCloudL, sprSDCloudL));
   426                           DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
   430                           DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
   427                           end;
   431                           end;
   428               vgtFlake: begin
   432               vgtFlake: if not (worldIsShifted) then
   429                         sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
   433                             begin
   430                         if speedlessFlakes then
   434                             sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
   431                             DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   435                             if speedlessFlakes then
   432                         else
   436                                 DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   433                             DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   437                             else
   434                         end;
   438                                 DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
       
   439                             end;
   435                 end;
   440                 end;
   436             if (Gear^.Tint <> $FFFFFFFF) then
   441             if (Gear^.Tint <> $FFFFFFFF) then
   437                 untint;
   442                 untint;
   438             Gear:= Gear^.NextGear
   443             Gear:= Gear^.NextGear
   439             end
   444             end
   444         while Gear <> nil do
   449         while Gear <> nil do
   445             begin
   450             begin
   446             if Gear^.Tint <> $FFFFFFFF then
   451             if Gear^.Tint <> $FFFFFFFF then
   447                 Tint(Gear^.Tint);
   452                 Tint(Gear^.Tint);
   448             case Gear^.Kind of
   453             case Gear^.Kind of
   449                 vgtFlake: begin
   454                 vgtFlake: if (not worldIsShifted) then
   450                          sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
   455                               begin
   451                           if speedlessFlakes then
   456                               sprite:= GetSpriteByWind(GetSprite(sprFlake, sprSDFlake), GetSprite(sprFlakeL, sprSDFlakeL));
   452                               DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   457                               if speedlessFlakes then
   453                           else
   458                                   DrawSprite(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   454                               DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
   459                               else
   455                           end;
   460                                   DrawSpriteRotatedF(sprite, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
       
   461                               end;
   456                 vgtNoPlaceWarn:
   462                 vgtNoPlaceWarn:
   457                             DrawTexture(round(Gear^.X) + WorldDx - round(Gear^.Tex^.w * Gear^.Scale) div 2, round(Gear^.Y) + WorldDy - round(Gear^.Tex^.h * Gear^.Scale) div 2, Gear^.Tex, Gear^.Scale);
   463                             DrawTexture(round(Gear^.X) + WorldDx - round(Gear^.Tex^.w * Gear^.Scale) div 2, round(Gear^.Y) + WorldDy - round(Gear^.Tex^.h * Gear^.Scale) div 2, Gear^.Tex, Gear^.Scale);
   458                 end;
   464                 end;
   459             if (Gear^.Tint <> $FFFFFFFF) then
   465             if (Gear^.Tint <> $FFFFFFFF) then
   460                 untint;
   466                 untint;