hedgewars/uVisualGears.pas
changeset 4475 54e78c40970b
parent 4465 743673c67d0c
child 4521 96066d42c3f9
equal deleted inserted replaced
4473:b6487d2c15ad 4475:54e78c40970b
   371       end
   371       end
   372 end;
   372 end;
   373 
   373 
   374 procedure DrawVisualGears(Layer: LongWord);
   374 procedure DrawVisualGears(Layer: LongWord);
   375 var Gear: PVisualGear;
   375 var Gear: PVisualGear;
       
   376     tinted: boolean;
   376 begin
   377 begin
   377 Gear:= VisualGearsList;
   378 Gear:= VisualGearsList;
   378 case Layer of
   379 case Layer of
   379     0: while Gear <> nil do
   380     0: while Gear <> nil do
   380         begin
   381         begin
   381         Tint(Gear^.Tint);
   382         if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
   382         case Gear^.Kind of
   383         case Gear^.Kind of
   383             vgtFlake: if vobVelocity = 0 then
   384             vgtFlake: if vobVelocity = 0 then
   384                           DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   385                           DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
   385                       else
   386                       else
   386                           DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   387                           DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
   387             vgtCloud: DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
   388             vgtCloud: DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
   388             end;
   389             end;
       
   390         if Gear^.Tint <> $FFFFFFFF then Tint($FF,$FF,$FF,$FF);
   389         Gear:= Gear^.NextGear
   391         Gear:= Gear^.NextGear
   390         end;
   392         end;
   391     1: while Gear <> nil do
   393     1: while Gear <> nil do
   392         begin
   394         begin
   393         Tint(Gear^.Tint);
   395         tinted:= false;
       
   396         if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
   394         case Gear^.Kind of
   397         case Gear^.Kind of
   395             vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   398             vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   396             vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   399             vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
   397             vgtLineTrail: DrawLine(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 1.0, $FF, min(Gear^.Timer, $C0), min(Gear^.Timer, $80), min(Gear^.Timer, $FF));
   400             vgtLineTrail: DrawLine(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 1.0, $FF, min(Gear^.Timer, $C0), min(Gear^.Timer, $80), min(Gear^.Timer, $FF));
   398             vgtSpeechBubble: if (Gear^.Hedgehog^.Team <> CurrentTeam) and (Gear^.Tex <> nil) then 
   401             vgtSpeechBubble: if (Gear^.Hedgehog^.Team <> CurrentTeam) and (Gear^.Tex <> nil) then 
   399                     begin
   402                     begin
       
   403                     tinted:= true;
   400                     Tint($FF, $FF, $FF,  $66);
   404                     Tint($FF, $FF, $FF,  $66);
   401                     DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
   405                     DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
   402                     end
   406                     end
   403         end;
   407         end;
   404             if (cReducedQuality and rqFancyBoom) = 0 then
   408             if (cReducedQuality and rqFancyBoom) = 0 then
   406                     vgtSmoke: DrawSprite(sprSmoke, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   410                     vgtSmoke: DrawSprite(sprSmoke, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   407                     vgtSmokeWhite: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   411                     vgtSmokeWhite: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   408                     vgtDust: DrawSprite(sprDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   412                     vgtDust: DrawSprite(sprDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   409                     vgtFeather: begin
   413                     vgtFeather: begin
   410                             if Gear^.FrameTicks < 255 then
   414                             if Gear^.FrameTicks < 255 then
       
   415                                 begin
   411                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   416                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
       
   417                                 tinted:= true
       
   418                                 end;
   412                             DrawRotatedF(sprFeather, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   419                             DrawRotatedF(sprFeather, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   413                             end;
   420                             end;
   414                  end;
   421                  end;
       
   422         if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
   415         Gear:= Gear^.NextGear
   423         Gear:= Gear^.NextGear
   416         end;
   424         end;
   417     2: while Gear <> nil do
   425     2: while Gear <> nil do
   418         begin
   426         begin
   419         Tint(Gear^.Tint);
   427         tinted:= false;
       
   428         if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
   420         case Gear^.Kind of
   429         case Gear^.Kind of
   421             vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State);
   430             vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State);
   422             vgtBigExplosion: begin
   431             vgtBigExplosion: begin
       
   432                              tinted:= true;
   423                              Tint($FF, $FF, $FF, round($FF * (1 - power(Gear^.Timer / 250, 4))));
   433                              Tint($FF, $FF, $FF, round($FF * (1 - power(Gear^.Timer / 250, 4))));
   424                              DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
   434                              DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
   425                              end;
   435                              end;
   426             end;
   436             end;
   427         if (cReducedQuality and rqFancyBoom) = 0 then
   437         if (cReducedQuality and rqFancyBoom) = 0 then
   433                          else
   443                          else
   434                              DrawTextureF(SpritesData[sprFlame].Texture, Gear^.FrameTicks / 900, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, (RealTicks shr 7 + Gear^.Frame) mod 8, 1, 16, 16);
   444                              DrawTextureF(SpritesData[sprFlame].Texture, Gear^.FrameTicks / 900, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, (RealTicks shr 7 + Gear^.Frame) mod 8, 1, 16, 16);
   435                 vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
   445                 vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
   436                 vgtSteam: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   446                 vgtSteam: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   437                 vgtAmmo: begin
   447                 vgtAmmo: begin
       
   448                         tinted:= true;
   438                         Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
   449                         Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
   439                         DrawTextureF(ropeIconTex, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 32, 32);
   450                         DrawTextureF(ropeIconTex, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 32, 32);
   440                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
   451                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
   441                         end;
   452                         end;
   442                 vgtHealth:  begin
   453                 vgtHealth:  begin
       
   454                             tinted:= true;
   443                             case Gear^.Frame div 10 of
   455                             case Gear^.Frame div 10 of
   444                                 0:Tint(0, $FF, 0, round(Gear^.FrameTicks * $FF / 1000));
   456                                 0:Tint(0, $FF, 0, round(Gear^.FrameTicks * $FF / 1000));
   445                                 1:Tint($FF, 0, 0, round(Gear^.FrameTicks * $FF / 1000));
   457                                 1:Tint($FF, 0, 0, round(Gear^.FrameTicks * $FF / 1000));
   446                             end;
   458                             end;
   447                             DrawSprite(sprHealth, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, 0);
   459                             DrawSprite(sprHealth, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, 0);
   448                             end;
   460                             end;
   449                 vgtShell: begin
   461                 vgtShell: begin
   450                             if Gear^.FrameTicks < $FF then
   462                             if Gear^.FrameTicks < $FF then
       
   463                                 begin
   451                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   464                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
       
   465                                 tinted:= true
       
   466                                 end;
   452                             DrawRotatedF(sprShell, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   467                             DrawRotatedF(sprShell, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   453                             end;
   468                             end;
   454                   vgtEgg: begin
   469                   vgtEgg: begin
   455                             if Gear^.FrameTicks < $FF then
   470                             if Gear^.FrameTicks < $FF then
       
   471                                 begin
   456                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   472                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
       
   473                                 tinted:= true
       
   474                                 end;
   457                             DrawRotatedF(sprEgg, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   475                             DrawRotatedF(sprEgg, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   458                             end;
   476                             end;
   459                 vgtSplash: DrawSprite(sprSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
   477                 vgtSplash: DrawSprite(sprSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
   460                 vgtDroplet: DrawSprite(sprDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);
   478                 vgtDroplet: DrawSprite(sprDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);
   461                vgtBeeTrace: begin
   479                vgtBeeTrace: begin
   462                             if Gear^.FrameTicks < $FF then
   480                             if Gear^.FrameTicks < $FF then
   463                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
   481                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
   464                             else
   482                             else
   465                                 Tint($FF, $FF, $FF, $80);
   483                                 Tint($FF, $FF, $FF, $80);
       
   484                             tinted:= true;
   466                             DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
   485                             DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
   467                             end;
   486                             end;
   468                 vgtSmokeRing: begin
   487                 vgtSmokeRing: begin
       
   488                             tinted:= true;
   469                             Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
   489                             Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
   470                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
   490                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
   471                             end;
   491                             end;
   472                 vgtChunk: DrawRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   492                 vgtChunk: DrawRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   473                  vgtNote: DrawRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   493                  vgtNote: DrawRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   477             vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   497             vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   478             vgtSpeechBubble: if (Gear^.Hedgehog^.Team = CurrentTeam) and (Gear^.Tex <> nil) then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   498             vgtSpeechBubble: if (Gear^.Hedgehog^.Team = CurrentTeam) and (Gear^.Tex <> nil) then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   479             vgtHealthTag: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   499             vgtHealthTag: if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
   480             vgtCircle: DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer);
   500             vgtCircle: DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer);
   481         end;
   501         end;
       
   502         if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
   482         Gear:= Gear^.NextGear
   503         Gear:= Gear^.NextGear
   483         end
   504         end
   484     end;
   505     end;
   485 Tint($FFFFFFFF);
       
   486 end;
   506 end;
   487 
   507 
   488 function  VisualGearByUID(uid : Longword) : PVisualGear;
   508 function  VisualGearByUID(uid : Longword) : PVisualGear;
   489 var vg: PVisualGear;
   509 var vg: PVisualGear;
   490 begin
   510 begin