hedgewars/uGearsRender.pas
branchwebgl
changeset 9950 2759212a27de
parent 9521 8054d9d775fd
parent 9809 1e32628eb167
child 10015 4feced261c68
--- a/hedgewars/uGearsRender.pas	Fri Oct 11 17:43:13 2013 +0200
+++ b/hedgewars/uGearsRender.pas	Sat Jan 04 23:55:54 2014 +0400
@@ -77,7 +77,7 @@
 
     glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]);
     glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2);
-    Tint($FF, $FF, $FF, $FF);
+    untint;
 
     glPopMatrix;
 
@@ -235,7 +235,7 @@
         DrawSprite(sprHHDeath, ox - 16, oy - 26, Gear^.Pos);
         Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
         DrawSprite(sprHHDeath, ox - 16, oy - 26, Gear^.Pos + 8);
-        Tint($FF, $FF, $FF, $FF);
+        untint;
         exit
         end
     else if (Gear^.State and gstHHGone) <> 0 then
@@ -276,7 +276,7 @@
         begin
         Tint($00, $FF, $40, $40);
         DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
-        Tint($FF, $FF, $FF, $FF)
+        untint
         end;
 
 
@@ -375,11 +375,15 @@
             CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
             CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
 
-
-            DrawTextureRotated(HH^.Team^.CrosshairTex,
+            setTintAdd(true);
+            Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
+            DrawTextureRotated(CrosshairTexture,
                     12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0,
-                    sign * (Gear^.Angle * 180.0) / cMaxAngle);
+                    sign * m * (Gear^.Angle * 180.0) / cMaxAngle);
+            untint;
+            setTintAdd(false);
             end;
+
         hx:= ox + 8 * sign;
         hy:= oy - 2;
         aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
@@ -434,7 +438,7 @@
                                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
                                     DrawTextureRotatedF(HatTex, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32,
                                         i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
-                                    Tint($FF, $FF, $FF, $FF)
+                                    untint
                                     end
                                 end
                     end;
@@ -471,7 +475,7 @@
                                     sign,
                                     32,
                                     32);
-                                Tint($FF, $FF, $FF, $FF)
+                                untint
                                 end
                             end;
                     defaultPos:= false
@@ -675,18 +679,19 @@
                              DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA);
                              //Tint($FF, $0, $0, $AA);
                              //DrawTexture(ox - 240, oy - 240, SpritesData[sprVampiric].Texture, 10);
-                             //Tint($FF, $FF, $FF, $FF);
+                             //untint;
                              end;
                 amVampiric: DrawSpriteRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
                 amRCPlane: begin
                     DrawSpriteRotated(sprHandPlane, hx, hy, sign, 0);
                     defaultPos:= false
                     end;
+                amRubber,
                 amGirder: begin
                     DrawSpriteRotated(sprHandConstruction, hx, hy, sign, aangle);
                     if WorldEdge = weWrap then
                         begin
-                        if hwRound(Gear^.X) < leftX+256 then
+                        if hwRound(Gear^.X) < LongInt(leftX) + 256 then
                             DrawSpriteClipped(sprGirder,
                                             rightX+(ox-leftX)-256,
                                             oy-256,
@@ -844,9 +849,9 @@
                         sign,
                         32,
                         32);
-                    Tint($FF, $FF, $FF, $FF)
+                    untint
                     end;
-                if HH^.Team^.hasGone then Tint($FF, $FF, $FF, $FF)
+                if HH^.Team^.hasGone then untint
                 end
             else
                 begin
@@ -869,7 +874,7 @@
                         sign*m,
                         32,
                         32);
-                    Tint($FF, $FF, $FF, $FF)
+                    untint
                     end
                 end
         end;
@@ -929,7 +934,7 @@
                 DrawTextureCentered(ox, t, Team^.NameTagTex)
                 end;
             if (cTagsMask and htTransparent) <> 0 then
-                Tint($FF, $FF, $FF, $FF)
+                untint
             end;
         if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
             begin
@@ -957,7 +962,7 @@
         DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
         end;
 
-    if Gear^.Invulnerable then
+    if (Gear^.Hedgehog^.Effects[heInvulnerable] <> 0) then
         begin
         Tint($FF, $FF, $FF, max($40, round($FF * abs(1 - ((RealTicks div 2 + Gear^.uid * 491) mod 1500) / 750))));
         DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
@@ -980,7 +985,7 @@
 
 
         if HH^.Effects[heFrozen] < 150000 then
-            Tint($FF, $FF, $FF, $FF);
+            untint;
         end;
 
 
@@ -991,7 +996,7 @@
         Tint($FF, 0, 0, max($40, round($FF * abs(1 - (RealTicks mod 1500) / 750))));
         DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
         end;
-        Tint($FF, $FF, $FF, $FF)
+        untint
 end;
 
 
@@ -1029,7 +1034,7 @@
                   if Gear^.Tag < 0 then aangle:= 360-aangle;
                   Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
                   DrawSpriteRotatedF(sprPlane, x, y, 0, Gear^.Tag, aangle - 90);
-                  Tint($FF, $FF, $FF, $FF);
+                  untint;
                   DrawSpriteRotatedF(sprPlane, x, y, 1, Gear^.Tag, aangle - 90)
                   end;
        gtBall: DrawSpriteRotatedF(sprBalls, x, y, Gear^.Tag,0, Gear^.DirAngle);
@@ -1057,7 +1062,7 @@
                         Tint($f5, $db, $35, max($40, round($FF * abs(1 - (GameTicks mod 1500) / (750 + Gear^.Health)))));
                         //Tint($FF, $FF, $FF, max($40, round($FF * abs(1 - (RealTicks mod 1500) / 750))));
                         DrawSprite(sprVampiric, x - 24, y - 24, 0);
-                        Tint($FF, $FF, $FF, $FF)
+                        untint
                         end
                     end;
              gtBee: DrawSpriteRotatedF(sprBee, x, y, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
@@ -1151,7 +1156,7 @@
        gtAirAttack: begin
                     Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF);
                     DrawSpriteRotatedF(sprAirplane, x, y, 0, Gear^.Tag, 0);
-                    Tint($FF, $FF, $FF, $FF);
+                    untint;
                     DrawSpriteRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0);
                     end;
          gtAirBomb: DrawSpriteRotated(sprAirBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
@@ -1165,7 +1170,7 @@
           gtTarget: begin
                     Tint($FF, $FF, $FF, round($FF * Gear^.Timer / 1000));
                     DrawSprite(sprTarget, x - 16, y - 16, 0);
-                    Tint($FF, $FF, $FF, $FF);
+                    untint;
                     end;
           gtMortar: DrawSpriteRotated(sprMortar, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
           gtCake: if Gear^.Pos = 6 then
@@ -1219,7 +1224,7 @@
                         Tint($FF, $FF, $FF, $10);
                         for i:= 8 downto 1 do
                             DrawTextureF(SpritesData[sprPiano].Texture, 1, x, y - hwRound(Gear^.dY * 4 * i), 0, 1, 128, 128);
-                        Tint($FF, $FF, $FF, $FF)
+                        untint
                         end;
                     DrawTextureF(SpritesData[sprPiano].Texture, 1, x, y, 0, 1, 128, 128);
                     end;
@@ -1231,13 +1236,13 @@
                     else
                         Tint($C0, $C0, $00, $C0);
                     DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360);
-                    Tint($FF, $FF, $FF, $FF)
+                    untint
                     end;
      gtResurrector: begin
                     DrawSpriteRotated(sprCross, x, y, 0, 0);
                     Tint($f5, $db, $35, max($00, round($C0 * abs(1 - (GameTicks mod 6000) / 3000))));
                     DrawTexture(x - 108, y - 108, SpritesData[sprVampiric].Texture, 4.5);
-                    Tint($FF, $FF, $FF, $FF);
+                    untint;
                     end;
       gtNapalmBomb: DrawSpriteRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
            gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0  then
@@ -1250,7 +1255,7 @@
                         DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle);
                         //DrawSpriteRotated(sprSnowDust, x, y, 0, Gear^.DirAngle);
                         //DrawTexture(x, y, SpritesData[sprVampiric].Texture, 0.1);
-                        Tint($FF, $FF, $FF, $FF);
+                        untint;
                         end
                     else //if not isInLag then
                         begin
@@ -1267,7 +1272,7 @@
 //DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer)
 //DrawSpriteRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle);
                         if Gear^.FlightTime > 0 then
-                            Tint($FF, $FF, $FF, $FF);
+                            untint;
                         end;
        //gtStructure: DrawSprite(sprTarget, x - 16, y - 16, 0);
           gtTardis: if Gear^.Pos <> 4 then
@@ -1278,16 +1283,16 @@
                             Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
                         DrawSprite(sprTardis, x-24, y-63,0);
                         if Gear^.Pos = 2 then
-                            Tint($FF, $FF, $FF, $FF)
+                            untint
                         else
                             Tint($FF,$FF,$FF,max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
                         DrawSprite(sprTardis, x-24, y-63,1);
                         if Gear^.Pos <> 2 then
-                            Tint($FF, $FF, $FF, $FF)
+                            untint
 (*
                         Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * abs(1 - (RealTicks mod 500) / 250))));
                         DrawTexture(x-6, y-70, SpritesData[sprVampiric].Texture, 0.25);
-                        Tint($FF, $FF, $FF, $FF)
+                        untint
 *)
                         end;
             gtIceGun: begin
@@ -1325,7 +1330,7 @@
          end;
       if Gear^.RenderTimer and (Gear^.Tex <> nil) then
           DrawTextureCentered(x + 8, y + 8, Gear^.Tex);
-    if Gear^.State and gstFrozen <> 0 then Tint($FF, $FF, $FF, $FF)
+    if Gear^.State and gstFrozen <> 0 then untint
 end;
 
 end.