hedgewars/uVisualGears.pas
changeset 3376 faee68a28b82
parent 3326 7f57fc2bf630
child 3390 1d4926d10a9e
equal deleted inserted replaced
3375:88bb88294e06 3376:faee68a28b82
   333 inc(Gear^.Timer, Steps);
   333 inc(Gear^.Timer, Steps);
   334 if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear)
   334 if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear)
   335 else
   335 else
   336     begin
   336     begin
   337     Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4;
   337     Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4;
   338     Gear^.alpha := -1.0 * (power(Gear^.Timer/350, 4) - 1);
   338     Gear^.alpha := 1 - power(Gear^.Timer / 350, 4);
       
   339     if Gear^.alpha < 0 then Gear^.alpha:= 0;
   339     end;
   340     end;
   340 end;
   341 end;
   341 
   342 
   342 procedure doStepFeather(Gear: PVisualGear; Steps: Longword);
   343 procedure doStepFeather(Gear: PVisualGear; Steps: Longword);
   343 begin
   344 begin
   753                 case Gear^.Kind of
   754                 case Gear^.Kind of
   754                     vgtSmoke: DrawSprite(sprSmoke, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   755                     vgtSmoke: DrawSprite(sprSmoke, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   755                     vgtSmokeWhite: DrawSprite(sprSmokeWhite, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   756                     vgtSmokeWhite: DrawSprite(sprSmokeWhite, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   756                     vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   757                     vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
   757                     vgtFeather: begin
   758                     vgtFeather: begin
   758                             if Gear^.FrameTicks < 250 then
   759                             if Gear^.FrameTicks < 255 then
   759                                 glColor4f(1, 1, 1, Gear^.FrameTicks / 250);
   760                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   760                             DrawRotatedF(sprFeather, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   761                             DrawRotatedF(sprFeather, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   761                             if Gear^.FrameTicks < 250 then
   762                             if Gear^.FrameTicks < 255 then
   762                                 glColor4f(1, 1, 1, 1);
   763                                 Tint($FFFFFFFF);
   763                             end;
   764                             end;
   764                 end;
   765                 end;
   765         Gear:= Gear^.NextGear
   766         Gear:= Gear^.NextGear
   766         end;
   767         end;
   767     2: while Gear <> nil do
   768     2: while Gear <> nil do
   772                 vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   773                 vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   773                 vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
   774                 vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8);
   774                 vgtBubble: DrawSprite(sprBubbles, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
   775                 vgtBubble: DrawSprite(sprBubbles, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
   775                 vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   776                 vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
   776                 vgtAmmo: begin
   777                 vgtAmmo: begin
   777                         glColor4f(1, 1, 1, Gear^.alpha);
   778                         Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
   778                         DrawTextureF(ropeIconTex, Gear^.scale, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 32, 32);
   779                         DrawTextureF(ropeIconTex, Gear^.scale, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 32, 32);
   779                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
   780                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
   780                         glColor4f(1, 1, 1, 1);
   781                         Tint($FFFFFFFF);
   781                         end;
   782                         end;
   782                 vgtHealth:  begin
   783                 vgtHealth:  begin
   783                             case Gear^.Frame div 10 of
   784                             case Gear^.Frame div 10 of
   784                                 0:glColor4f(0, 1, 0, Gear^.FrameTicks / 1000);
   785                                 0:Tint(0, $FF, 0, floor(Gear^.FrameTicks * $FF / 1000));
   785                                 1:glColor4f(1, 0, 0, Gear^.FrameTicks / 1000);
   786                                 1:Tint($FF, 0, 0, floor(Gear^.FrameTicks * $FF / 1000));
   786                             end;
   787                             end;
   787                             DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0);
   788                             DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0);
   788                             glColor4f(1, 1, 1, 1);
   789                             Tint($FFFFFFFF);
   789                             end;
   790                             end;
   790                 vgtShell: begin
   791                 vgtShell: begin
   791                             if Gear^.FrameTicks < 250 then
   792                             if Gear^.FrameTicks < $FF then
   792                                 glColor4f(1, 1, 1, Gear^.FrameTicks / 250);
   793                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   793                             DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   794                             DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   794                             if Gear^.FrameTicks < 250 then
   795                             if Gear^.FrameTicks < $FF then
   795                                 glColor4f(1, 1, 1, 1);
   796                                 Tint($FFFFFFFF);
   796                             end;
   797                             end;
   797                   vgtEgg: begin
   798                   vgtEgg: begin
   798                             if Gear^.FrameTicks < 250 then
   799                             if Gear^.FrameTicks < $FF then
   799                                 glColor4f(1, 1, 1, Gear^.FrameTicks / 250);
   800                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
   800                             DrawRotatedF(sprEgg, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   801                             DrawRotatedF(sprEgg, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
   801                             if Gear^.FrameTicks < 250 then
   802                             if Gear^.FrameTicks < $FF then
   802                                 glColor4f(1, 1, 1, 1);
   803                                 Tint($FFFFFFFF);
   803                             end;
   804                             end;
   804                 vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 40, hwRound(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
   805                 vgtSplash: DrawSprite(sprSplash, hwRound(Gear^.X) + WorldDx - 40, hwRound(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
   805                 vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
   806                 vgtDroplet: DrawSprite(sprDroplet, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);
   806                vgtBeeTrace: begin
   807                vgtBeeTrace: begin
   807                             if Gear^.FrameTicks < 250 then
   808                             if Gear^.FrameTicks < $FF then
   808                                 glColor4f(1, 1, 1, Gear^.FrameTicks / 500)
   809                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
   809                             else
   810                             else
   810                                 glColor4f(1, 1, 1, 0.5);
   811                                 Tint($80FFFFFF);
   811                             DrawRotatedF(sprBeeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
   812                             DrawRotatedF(sprBeeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
   812                             glColor4f(1, 1, 1, 1);
   813                             Tint($FFFFFFFF);
   813                             end;
   814                             end;
   814                 vgtSmokeRing: begin
   815                 vgtSmokeRing: begin
   815                             glColor4f(1, 1, 1, Gear^.alpha);
   816                             Tint($FF, $FF, $FF, floor(Gear^.alpha * $FF));
   816                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
   817                             DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
   817                             glColor4f(1, 1, 1, 1);
   818                             Tint($FFFFFFFF);
   818                             end;
   819                             end;
   819             end;
   820             end;
   820         case Gear^.Kind of
   821         case Gear^.Kind of
   821             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   822             vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   822             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   823             vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);