hedgewars/uGears.pas
changeset 3376 faee68a28b82
parent 3355 dc9e61e67484
child 3378 4f2185ed8ca8
equal deleted inserted replaced
3375:88bb88294e06 3376:faee68a28b82
   960 sx:= hwRound(Gear^.X) + 1 + WorldDx;
   960 sx:= hwRound(Gear^.X) + 1 + WorldDx;
   961 sy:= hwRound(Gear^.Y) - 3 + WorldDy;
   961 sy:= hwRound(Gear^.Y) - 3 + WorldDy;
   962 
   962 
   963 if HH^.Effects[hePoisoned] then
   963 if HH^.Effects[hePoisoned] then
   964     begin
   964     begin
   965     glColor4f(0.25, 1, 0, 0.25);
   965     Tint($4000FF40);
   966     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
   966     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
   967     glColor4f(1, 1, 1, 1)
   967     Tint($FFFFFFFF)
   968     end;
   968     end;
   969 
   969 
   970 if ((Gear^.State and gstWinner) <> 0) and
   970 if ((Gear^.State and gstWinner) <> 0) and
   971    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
   971    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
   972     begin
   972     begin
  1045                 glDisable(GL_TEXTURE_2D);
  1045                 glDisable(GL_TEXTURE_2D);
  1046                 glEnable(GL_LINE_SMOOTH);
  1046                 glEnable(GL_LINE_SMOOTH);
  1047 
  1047 
  1048                 glLineWidth(1.0);
  1048                 glLineWidth(1.0);
  1049 
  1049 
  1050                 glColor4ub($FF, $00, $00, $C0);
  1050                 Tint($C00000FF);
  1051                 VertexBuffer[0].X:= hx + WorldDx;
  1051                 VertexBuffer[0].X:= hx + WorldDx;
  1052                 VertexBuffer[0].Y:= hy + WorldDy;
  1052                 VertexBuffer[0].Y:= hy + WorldDy;
  1053                 VertexBuffer[1].X:= tx + WorldDx;
  1053                 VertexBuffer[1].X:= tx + WorldDx;
  1054                 VertexBuffer[1].Y:= ty + WorldDy;
  1054                 VertexBuffer[1].Y:= ty + WorldDy;
  1055 
  1055 
  1056                 glEnableClientState(GL_VERTEX_ARRAY);
  1056                 glEnableClientState(GL_VERTEX_ARRAY);
  1057                 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
  1057                 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
  1058                 glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
  1058                 glDrawArrays(GL_LINES, 0, Length(VertexBuffer));
  1059                 glColor4f(1, 1, 1, 1);
  1059                 Tint($FFFFFFFF);
  1060                 glEnable(GL_TEXTURE_2D);
  1060                 glEnable(GL_TEXTURE_2D);
  1061                 glDisable(GL_LINE_SMOOTH);
  1061                 glDisable(GL_LINE_SMOOTH);
  1062                 end;
  1062                 end;
  1063             end;
  1063             end;
  1064         // draw crosshair
  1064         // draw crosshair
  1452     if ((Gear^.State and not gstWinner) = 0)
  1452     if ((Gear^.State and not gstWinner) = 0)
  1453         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
  1453         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
  1454         begin
  1454         begin
  1455         t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;
  1455         t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;
  1456         if (cTagsMask and htTransparent) <> 0 then
  1456         if (cTagsMask and htTransparent) <> 0 then
  1457             glColor4f(1, 1, 1, 0.5);
  1457             Tint($80FFFFFF);
  1458         if ((cTagsMask and htHealth) <> 0) then
  1458         if ((cTagsMask and htHealth) <> 0) then
  1459             begin
  1459             begin
  1460             dec(t, HealthTagTex^.h + 2);
  1460             dec(t, HealthTagTex^.h + 2);
  1461             DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex)
  1461             DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex)
  1462             end;
  1462             end;
  1469             begin
  1469             begin
  1470             dec(t, Team^.NameTagTex^.h + 2);
  1470             dec(t, Team^.NameTagTex^.h + 2);
  1471             DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex)
  1471             DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex)
  1472             end;
  1472             end;
  1473         if (cTagsMask and htTransparent) <> 0 then
  1473         if (cTagsMask and htTransparent) <> 0 then
  1474             glColor4f(1, 1, 1, 1)
  1474             Tint($FFFFFFFF)
  1475         end;
  1475         end;
  1476     if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
  1476     if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog
  1477         begin
  1477         begin
  1478         if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
  1478         if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
  1479             DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy,
  1479             DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy,
  1485         end
  1485         end
  1486     end;
  1486     end;
  1487 
  1487 
  1488 if HH^.Effects[hePoisoned] then
  1488 if HH^.Effects[hePoisoned] then
  1489     begin
  1489     begin
  1490     glColor4f(0.25, 1, 0, 0.5);
  1490     Tint($8000FF40);
  1491     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
  1491     DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
  1492     glColor4f(1, 1, 1, 1)
       
  1493     end;
  1492     end;
  1494 
  1493 
  1495 if Gear^.Invulnerable then
  1494 if Gear^.Invulnerable then
  1496     begin
  1495     begin
  1497     glColor4f(1, 1, 1, 0.25 + abs(1 - ((RealTicks div 2 + Gear^.uid * 491) mod 1500) / 750));
  1496     Tint($FF, $FF, $FF, max($40, floor($FF * abs(1 - 2 * ((RealTicks div 2 + Gear^.uid * 491) mod 1500) / 750))));
  1498     DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
  1497     DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
  1499     glColor4f(1, 1, 1, 1);
       
  1500     end;
  1498     end;
  1501 if cVampiric and
  1499 if cVampiric and
  1502    (CurrentHedgehog^.Gear <> nil) and
  1500    (CurrentHedgehog^.Gear <> nil) and
  1503    (CurrentHedgehog^.Gear = Gear) then
  1501    (CurrentHedgehog^.Gear = Gear) then
  1504     begin
  1502     begin
  1505     glColor4f(1, 1, 1, 0.25 + abs(1 - (RealTicks mod 1500) / 750));
  1503     Tint($FF, $FF, $FF, max($40, floor($FF * abs(1 - (RealTicks mod 1500) / 750))));
  1506     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
  1504     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
  1507     glColor4f(1, 1, 1, 1);
  1505     end;
  1508     end;
  1506     Tint($FFFFFFFF)
  1509 end;
  1507 end;
  1510 
  1508 
  1511 procedure DrawRopeLinesRQ(Gear: PGear);
  1509 procedure DrawRopeLinesRQ(Gear: PGear);
  1512 begin
  1510 begin
  1513 with RopePoints do
  1511 with RopePoints do
  1527 
  1525 
  1528     glTranslatef(WorldDx, WorldDy, 0);
  1526     glTranslatef(WorldDx, WorldDy, 0);
  1529 
  1527 
  1530     glLineWidth(4.0);
  1528     glLineWidth(4.0);
  1531 
  1529 
  1532     glColor4f(0.8, 0.8, 0.8, 1);
  1530     Tint($FFC0C0C0);
  1533 
  1531 
  1534     glEnableClientState(GL_VERTEX_ARRAY);
  1532     glEnableClientState(GL_VERTEX_ARRAY);
  1535     glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]);
  1533     glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]);
  1536     glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2);
  1534     glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2);
  1537     glColor4f(1, 1, 1, 1);
  1535     Tint($FFFFFFFF);
  1538 
  1536 
  1539     glPopMatrix;
  1537     glPopMatrix;
  1540 
  1538 
  1541     glEnable(GL_TEXTURE_2D);
  1539     glEnable(GL_TEXTURE_2D);
  1542     //glDisable(GL_LINE_SMOOTH)
  1540     //glDisable(GL_LINE_SMOOTH)
  1731                     if not PHedgehog(Gear^.Hedgehog)^.Unplaced then DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0);
  1729                     if not PHedgehog(Gear^.Hedgehog)^.Unplaced then DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, Gear^.Pos, hwSign(HHGear^.dX), 0);
  1732                     DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
  1730                     DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
  1733                     end;
  1731                     end;
  1734         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12);
  1732         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12);
  1735           gtTarget: begin
  1733           gtTarget: begin
  1736                     glColor4f(1, 1, 1, Gear^.Timer / 1000);
  1734                     Tint($FF, $FF, $FF, floor($FF * Gear^.Timer / 1000));
  1737                     DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
  1735                     DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
  1738                     glColor4f(1, 1, 1, 1);
  1736                     Tint($FFFFFFFF);
  1739                     end;
  1737                     end;
  1740           gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1738           gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1741           gtCake: if Gear^.Pos = 6 then
  1739           gtCake: if Gear^.Pos = 6 then
  1742                      DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90)
  1740                      DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90)
  1743                   else
  1741                   else
  1775                         end
  1773                         end
  1776                     else
  1774                     else
  1777                         DrawTextureF(SpritesData[sprBirdy].Texture, 1, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
  1775                         DrawTextureF(SpritesData[sprBirdy].Texture, 1, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
  1778                     end;
  1776                     end;
  1779     gtBigExplosion: begin
  1777     gtBigExplosion: begin
  1780                     glColor4f(1, 1, 1, -1.0 * (power(Gear^.Timer/250, 4) - 1));
  1778                     Tint($FF, $FF, $FF, floor($FF * (1 - power(Gear^.Timer / 250, 4))));
  1781                     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);
  1779                     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);
  1782                     glColor4f(1, 1, 1, 1);
  1780                     Tint($FFFFFFFF);
  1783                     end;
  1781                     end;
  1784              gtEgg: DrawRotatedTextureF(SpritesData[sprEgg].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 16, 16, Gear^.DirAngle);
  1782              gtEgg: DrawRotatedTextureF(SpritesData[sprEgg].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 16, 16, Gear^.DirAngle);
  1785            gtPiano: begin
  1783            gtPiano: begin
  1786                     if (Gear^.State and gstDrowning) = 0 then
  1784                     if (Gear^.State and gstDrowning) = 0 then
  1787                         begin
  1785                         begin
  1788                         glColor4f(1, 1, 1, 0.0625);
  1786                         Tint($10FFFFFF);
  1789                         for i:= 8 downto 1 do
  1787                         for i:= 8 downto 1 do
  1790                             DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy - hwRound(Gear^.dY * 4 * i), 0, 1, 128, 128, 0);
  1788                             DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy - hwRound(Gear^.dY * 4 * i), 0, 1, 128, 128, 0);
  1791                         glColor4f(1, 1, 1, 1)
  1789                         Tint($FFFFFFFF)
  1792                         end;
  1790                         end;
  1793                     DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 128, 128, 0);
  1791                     DrawRotatedTextureF(SpritesData[sprPiano].Texture, 1, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 128, 128, 0);
  1794                     end;
  1792                     end;
  1795          end;
  1793          end;
  1796       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(hwRound(Gear^.X) + 8 + WorldDx, hwRound(Gear^.Y) + 8 + WorldDy, Gear^.Tex);
  1794       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(hwRound(Gear^.X) + 8 + WorldDx, hwRound(Gear^.Y) + 8 + WorldDy, Gear^.Tex);