hedgewars/uVisualGears.pas
changeset 3475 95345f98da19
parent 3447 2f1c2b7215e6
child 3513 f589230fa21b
equal deleted inserted replaced
3474:c6d308f5a431 3475:95345f98da19
    41         Kind: TVisualGearType;
    41         Kind: TVisualGearType;
    42         doStep: TVGearStepProcedure;
    42         doStep: TVGearStepProcedure;
    43         Tex: PTexture;
    43         Tex: PTexture;
    44         alpha, scale: GLfloat;
    44         alpha, scale: GLfloat;
    45         Hedgehog: pointer;
    45         Hedgehog: pointer;
    46         Text: shortstring
    46         Text: shortstring;
       
    47         Tint: Longword;
    47         end;
    48         end;
    48 
    49 
    49 procedure initModule;
    50 procedure initModule;
    50 procedure freeModule;
    51 procedure freeModule;
    51 
    52 
   150 gear^.X:= int2hwFloat(X);
   151 gear^.X:= int2hwFloat(X);
   151 gear^.Y:= int2hwFloat(Y);
   152 gear^.Y:= int2hwFloat(Y);
   152 gear^.Kind := Kind;
   153 gear^.Kind := Kind;
   153 gear^.doStep:= doStepHandlers[Kind];
   154 gear^.doStep:= doStepHandlers[Kind];
   154 gear^.State:= 0;
   155 gear^.State:= 0;
       
   156 gear^.Tint:= $FFFFFFFF;
   155 
   157 
   156 with gear^ do
   158 with gear^ do
   157     case Kind of
   159     case Kind of
   158     vgtFlake: begin
   160     vgtFlake: begin
   159                 Timer:= 0;
   161                 Timer:= 0;
   378 begin
   380 begin
   379 Gear:= VisualGearsList;
   381 Gear:= VisualGearsList;
   380 case Layer of
   382 case Layer of
   381     0: while Gear <> nil do
   383     0: while Gear <> nil do
   382         begin
   384         begin
       
   385         Tint(Gear^.Tint);
   383         case Gear^.Kind of
   386         case Gear^.Kind of
   384             vgtFlake: if vobVelocity = 0 then
   387             vgtFlake: if vobVelocity = 0 then
   385                         DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   388                         DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   386                     else
   389                     else
   387                         DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   390                         DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   389             end;
   392             end;
   390         Gear:= Gear^.NextGear
   393         Gear:= Gear^.NextGear
   391         end;
   394         end;
   392     1: while Gear <> nil do
   395     1: while Gear <> nil do
   393         begin
   396         begin
       
   397         Tint(Gear^.Tint);
   394         case Gear^.Kind of
   398         case Gear^.Kind of
   395             vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
   399             vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
   396             vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
   400             vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
   397         end;
   401         end;
   398             if not cReducedQuality then
   402             if not cReducedQuality then
   402                     vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   406                     vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   403                     vgtFeather: begin
   407                     vgtFeather: begin
   404                             if Gear^.FrameTicks < 255 then
   408                             if Gear^.FrameTicks < 255 then
   405                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   409                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   406                             DrawRotatedF(sprFeather, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   410                             DrawRotatedF(sprFeather, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   407                             if Gear^.FrameTicks < 255 then
       
   408                                 Tint($FF, $FF, $FF, $FF);
       
   409                             end;
   411                             end;
   410                  end;
   412                  end;
   411         Gear:= Gear^.NextGear
   413         Gear:= Gear^.NextGear
   412         end;
   414         end;
   413     2: while Gear <> nil do
   415     2: while Gear <> nil do
   414         begin
   416         begin
       
   417         Tint(Gear^.Tint);
   415         case Gear^.Kind of
   418         case Gear^.Kind of
   416             vgtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State);
   419             vgtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 32 + WorldDy, Gear^.State);
   417             vgtBigExplosion: begin
   420             vgtBigExplosion: begin
   418                              Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
   421                              Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
   419                              DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
   422                              DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
   420                              Tint($FF, $FF, $FF, $FF);
       
   421                              end;
   423                              end;
   422             end;
   424             end;
   423         if not cReducedQuality then
   425         if not cReducedQuality then
   424             case Gear^.Kind of
   426             case Gear^.Kind of
   425                 vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   427                 vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   429                 vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   431                 vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   430                 vgtAmmo: begin
   432                 vgtAmmo: begin
   431                         Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
   433                         Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
   432                         DrawTextureF(ropeIconTex, Gear^.scale, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 32, 32);
   434                         DrawTextureF(ropeIconTex, Gear^.scale, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 32, 32);
   433                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
   435                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
   434                         Tint($FF, $FF, $FF, $FF);
       
   435                         end;
   436                         end;
   436                 vgtHealth:  begin
   437                 vgtHealth:  begin
   437                             case Gear^.Frame div 10 of
   438                             case Gear^.Frame div 10 of
   438                                 0:Tint(0, $FF, 0, floor(Gear^.FrameTicks * $FF / 1000));
   439                                 0:Tint(0, $FF, 0, floor(Gear^.FrameTicks * $FF / 1000));
   439                                 1:Tint($FF, 0, 0, floor(Gear^.FrameTicks * $FF / 1000));
   440                                 1:Tint($FF, 0, 0, floor(Gear^.FrameTicks * $FF / 1000));
   440                             end;
   441                             end;
   441                             DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0);
   442                             DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0);
   442                             Tint($FF, $FF, $FF, $FF);
       
   443                             end;
   443                             end;
   444                 vgtShell: begin
   444                 vgtShell: begin
   445                             if Gear^.FrameTicks < $FF then
   445                             if Gear^.FrameTicks < $FF then
   446                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   446                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   447                             DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   447                             DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   448                             if Gear^.FrameTicks < $FF then
       
   449                                 Tint($FF, $FF, $FF, $FF);
       
   450                             end;
   448                             end;
   451                   vgtEgg: begin
   449                   vgtEgg: begin
   452                             if Gear^.FrameTicks < $FF then
   450                             if Gear^.FrameTicks < $FF then
   453                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   451                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   454                             DrawRotatedF(sprEgg, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   452                             DrawRotatedF(sprEgg, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   455                             if Gear^.FrameTicks < $FF then
       
   456                                 Tint($FF, $FF, $FF, $FF);
       
   457                             end;
   453                             end;
   458                 vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 40, hwRound(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
   454                 vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 40, hwRound(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
   459                 vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
   455                 vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
   460                vgtBeeTrace: begin
   456                vgtBeeTrace: begin
   461                             if Gear^.FrameTicks < $FF then
   457                             if Gear^.FrameTicks < $FF then
   462                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
   458                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
   463                             else
   459                             else
   464                                 Tint($FF, $FF, $FF, $80);
   460                                 Tint($FF, $FF, $FF, $80);
   465                             DrawRotatedF(sprBeeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
   461                             DrawRotatedF(sprBeeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
   466                             Tint($FF, $FF, $FF, $FF);
       
   467                             end;
   462                             end;
   468                 vgtSmokeRing: begin
   463                 vgtSmokeRing: begin
   469                             Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
   464                             Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
   470                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
   465                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
   471                             Tint($FF, $FF, $FF, $FF);
       
   472                             end;
   466                             end;
   473             end;
   467             end;
   474         case Gear^.Kind of
   468         case Gear^.Kind of
   475             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   469             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   476             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   470             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);