hedgewars/uGearsRender.pas
changeset 14577 34e810295d08
parent 14558 5ae97eab70eb
child 14584 42f3d6860971
equal deleted inserted replaced
14576:1d3dc553829c 14577:34e810295d08
    67     end;
    67     end;
    68 
    68 
    69 if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then
    69 if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then
    70     begin
    70     begin
    71     EnableTexture(false);
    71     EnableTexture(false);
    72     //glEnable(GL_LINE_SMOOTH);
       
    73 
       
    74     
    72     
    75     Tint(Gear^.Tint shr 24 div 3, Gear^.Tint shr 16 and $FF div 3, Gear^.Tint shr 8 and $FF div 3, Gear^.Tint and $FF);
    73     Tint(Gear^.Tint shr 24 div 3, Gear^.Tint shr 16 and $FF div 3, Gear^.Tint shr 8 and $FF div 3, Gear^.Tint and $FF);
    76 
    74 
    77     n:= RopePoints.Count + 2;
    75     n:= RopePoints.Count + 2;
    78 
    76 
    90     untint;
    88     untint;
    91 
    89 
    92     openglPopMatrix();
    90     openglPopMatrix();
    93 
    91 
    94     EnableTexture(true);
    92     EnableTexture(true);
    95     //glDisable(GL_LINE_SMOOTH)
       
    96     end
    93     end
    97 end;
    94 end;
    98 
    95 
    99 
    96 
   100 function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt): LongInt;
    97 function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt): LongInt;
   424 
   421 
   425     if (Gear^.State and gstHHDriven) <> 0 then
   422     if (Gear^.State and gstHHDriven) <> 0 then
   426         begin
   423         begin
   427         if ((Gear^.State and (gstHHThinking or gstAnimation)) = 0) and
   424         if ((Gear^.State and (gstHHThinking or gstAnimation)) = 0) and
   428 /// If current ammo is active, and current ammo has alt attack and uses a crosshair  (rope, basically, right now, with no crosshair for parachute/saucer
   425 /// If current ammo is active, and current ammo has alt attack and uses a crosshair  (rope, basically, right now, with no crosshair for parachute/saucer
   429             (((CurAmmoGear <> nil) and //((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and
   426             (((CurAmmoGear <> nil) and
   430             // don't render crosshair/laser during kamikaze
   427             // don't render crosshair/laser during kamikaze
   431             ((CurAmmoGear^.AmmoType <> amKamikaze) or ((Gear^.State and gstAttacking) = 0)) and
   428             ((CurAmmoGear^.AmmoType <> amKamikaze) or ((Gear^.State and gstAttacking) = 0)) and
   432              ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0)) or
   429              ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0)) or
   433 /// If no current ammo is active, and the selected ammo uses a crosshair
   430 /// If no current ammo is active, and the selected ammo uses a crosshair
   434             ((CurAmmoGear = nil) and ((Ammoz[HH^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0) and ((Gear^.State and gstAttacked) = 0))) then
   431             ((CurAmmoGear = nil) and ((Ammoz[HH^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0) and ((Gear^.State and gstAttacked) = 0))) then
   814                 amSMine: DrawSpriteRotated(sprHandSMine, hx, hy, sign, aangle);
   811                 amSMine: DrawSpriteRotated(sprHandSMine, hx, hy, sign, aangle);
   815                 amKnife: DrawSpriteRotatedF(sprHandKnife, hx, hy, 0, sign, aangle);
   812                 amKnife: DrawSpriteRotatedF(sprHandKnife, hx, hy, 0, sign, aangle);
   816                 amSeduction: begin
   813                 amSeduction: begin
   817                              DrawSpriteRotated(sprHandSeduction, hx, hy, sign, aangle);
   814                              DrawSpriteRotated(sprHandSeduction, hx, hy, sign, aangle);
   818                              DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA);
   815                              DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA);
   819                              //Tint($FF, $0, $0, $AA);
       
   820                              //DrawTexture(ox - 240, oy - 240, SpritesData[sprVampiric].Texture, 10);
       
   821                              //untint;
       
   822                              end;
   816                              end;
   823                 amVampiric: DrawSpriteRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   817                 amVampiric: DrawSpriteRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
   824                 amRCPlane: begin
   818                 amRCPlane: begin
   825                     DrawSpriteRotated(sprHandPlane, hx, hy, sign, 0);
   819                     DrawSpriteRotated(sprHandPlane, hx, hy, sign, 0);
   826                     defaultPos:= false
   820                     defaultPos:= false
   913                     0,
   907                     0,
   914                     4,
   908                     4,
   915                     0);
   909                     0);
   916 
   910 
   917                 HatVisible:= true;
   911                 HatVisible:= true;
   918                 (* with HH^ do
       
   919                     if (HatTex <> nil)
       
   920                     and (HatVisibility > 0) then
       
   921                         DrawTextureF(HatTex,
       
   922                             HatVisibility,
       
   923                             sx,
       
   924                             sy - 5,
       
   925                             0,
       
   926                             sign,
       
   927                             32,
       
   928                             32); *)
       
   929             end;
   912             end;
   930 
   913 
   931             defaultPos:= false
   914             defaultPos:= false
   932         end;
   915         end;
   933 
   916 
  1097                 end
  1080                 end
  1098         end;
  1081         end;
  1099 
  1082 
  1100     if (Gear^.State and gstHHDriven) <> 0 then
  1083     if (Gear^.State and gstHHDriven) <> 0 then
  1101         begin
  1084         begin
  1102     (*    if (CurAmmoGear = nil) then
       
  1103             begin
       
  1104             amt:= CurrentHedgehog^.CurAmmoType;
       
  1105             case amt of
       
  1106                 amJetpack: DrawSprite(sprJetpack, sx-32, sy-32, 0);
       
  1107                 end
       
  1108             end; *)
       
  1109         if (CurAmmoGear = nil) then
  1085         if (CurAmmoGear = nil) then
  1110             begin
  1086             begin
  1111                 if ((Gear^.State and (gstAttacked or gstAnimation or gstHHJumping)) = 0)
  1087                 if ((Gear^.State and (gstAttacked or gstAnimation or gstHHJumping)) = 0)
  1112                 and (Gear^.Message and (gmLeft or gmRight) = 0) then
  1088                 and (Gear^.Message and (gmLeft or gmRight) = 0) then
  1113                 begin
  1089                 begin
  1187                 if (cTagsMask and htHealth) <> 0 then
  1163                 if (cTagsMask and htHealth) <> 0 then
  1188                     ty := ty - HealthTagTex^.h - 2;
  1164                     ty := ty - HealthTagTex^.h - 2;
  1189                 tx := ox;
  1165                 tx := ox;
  1190 
  1166 
  1191                 // don't go offscreen
  1167                 // don't go offscreen
  1192                 //tx := round(max(((-cScreenWidth + 16) / cScaleFactor) + SpritesData[sprFinger].Width div 2, min(((cScreenWidth - 16) / cScaleFactor) - SpritesData[sprFinger].Width div 2, tx)));
  1168                 t:= 32;
  1193                 //ty := round(max(cScreenHeight div 2 - ((cScreenHeight - 16) / cScaleFactor) + SpritesData[sprFinger].Height div 2, min(cScreenHeight div 2 - ((-cScreenHeight + SpritesData[sprFinger].Height) / (cScaleFactor)) - SpritesData[sprFinger].Width div 2 - 96, ty)));
       
  1194                 t:= 32;//trunc((SpritesData[sprFinger].Width + t) / cScaleFactor);
       
  1195                 tx := min(max(tx, ViewLeftX + t), ViewRightX  - t);
  1169                 tx := min(max(tx, ViewLeftX + t), ViewRightX  - t);
  1196                 t:= 32;//trunc((SpritesData[sprFinger].Height + t) / cScaleFactor);
  1170                 t:= 32;
  1197                 ty := min(ty, ViewBottomY - 96);
  1171                 ty := min(ty, ViewBottomY - 96);
  1198                 // don't overlap with HH or HH tags
  1172                 // don't overlap with HH or HH tags
  1199                 if ty < ViewTopY + t then
  1173                 if ty < ViewTopY + t then
  1200                     begin
  1174                     begin
  1201                     if abs(tx - ox) < abs(ty - oy)  then
  1175                     if abs(tx - ox) < abs(ty - oy)  then
  1270     vg: PVisualGear;
  1244     vg: PVisualGear;
  1271     i: Longword;
  1245     i: Longword;
  1272     aAngle: real;
  1246     aAngle: real;
  1273     startX, endX, startY, endY: LongInt;
  1247     startX, endX, startY, endY: LongInt;
  1274 begin
  1248 begin
  1275 	// airmine has its own sprite
  1249     // airmine has its own sprite
  1276     if (Gear^.State and gstFrozen <> 0) and (Gear^.Kind <> gtAirMine) then Tint($A0, $A0, $FF, $FF);
  1250     if (Gear^.State and gstFrozen <> 0) and (Gear^.Kind <> gtAirMine) then Tint($A0, $A0, $FF, $FF);
  1277     //if Gear^.State and gstFrozen <> 0 then Tint(IceColor or $FF);
       
  1278     if Gear^.Target.X <> NoPointX then
  1251     if Gear^.Target.X <> NoPointX then
  1279         if Gear^.AmmoType = amBee then
  1252         if Gear^.AmmoType = amBee then
  1280             DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
  1253             DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
  1281     else if Gear^.AmmoType = amIceGun then
  1254     else if Gear^.AmmoType = amIceGun then
  1282         //DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8)
       
  1283         //DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360)
       
  1284         DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1/(1+(RealTicks shr 8) mod 5), 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360)
  1255         DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1/(1+(RealTicks shr 8) mod 5), 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360)
  1285     else
  1256     else
  1286         begin
  1257         begin
  1287         if CurrentHedgehog <> nil then
  1258         if CurrentHedgehog <> nil then
  1288             Tint(CurrentHedgehog^.Team^.Clan^.Color shl 8 or $FF);
  1259             Tint(CurrentHedgehog^.Team^.Clan^.Color shl 8 or $FF);
  1341 
  1312 
  1342            gtGrave: begin
  1313            gtGrave: begin
  1343                     DrawTextureF(Gear^.Hedgehog^.Team^.GraveTex, 1, x, y, (RealTicks shr 7+Gear^.uid) and 15, 1, 32, 32);
  1314                     DrawTextureF(Gear^.Hedgehog^.Team^.GraveTex, 1, x, y, (RealTicks shr 7+Gear^.uid) and 15, 1, 32, 32);
  1344                     if Gear^.Health > 0 then
  1315                     if Gear^.Health > 0 then
  1345                         begin
  1316                         begin
  1346                         //Tint($33, $33, $FF, max($40, round($FF * abs(1 - (GameTicks mod (6000 div Gear^.Health)) / 750))));
       
  1347                         Tint($f5, $db, $35, max($40, round($FF * abs(1 - (RealTicks mod 1500) / (750 + Gear^.Health)))));
  1317                         Tint($f5, $db, $35, max($40, round($FF * abs(1 - (RealTicks mod 1500) / (750 + Gear^.Health)))));
  1348                         //Tint($FF, $FF, $FF, max($40, round($FF * abs(1 - (RealTicks mod 1500) / 750))));
       
  1349                         DrawSprite(sprVampiric, x - 24, y - 24, 0);
  1318                         DrawSprite(sprVampiric, x - 24, y - 24, 0);
  1350                         untint
  1319                         untint
  1351                         end
  1320                         end
  1352                     end;
  1321                     end;
  1353              gtBee: DrawSpriteRotatedF(sprBee, x, y, (RealTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1322              gtBee: DrawSpriteRotatedF(sprBee, x, y, (RealTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1580            gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0  then
  1549            gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0  then
  1581                         begin
  1550                         begin
  1582                         Tint(Gear^.Tint);
  1551                         Tint(Gear^.Tint);
  1583                         // Needs a nicer white texture to tint
  1552                         // Needs a nicer white texture to tint
  1584                         DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle);
  1553                         DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle);
  1585                         //DrawSpriteRotated(sprSnowDust, x, y, 0, Gear^.DirAngle);
       
  1586                         //DrawTexture(x, y, SpritesData[sprVampiric].Texture, 0.1);
       
  1587                         untint;
  1554                         untint;
  1588                         end
  1555                         end
  1589                     else //if not isInLag then
  1556                     else //if not isInLag then
  1590                         begin
  1557                         begin
  1591                         if isInLag and (Gear^.FlightTime < 256) then
  1558                         if isInLag and (Gear^.FlightTime < 256) then
  1596                             Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime));
  1563                             Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime));
  1597                         if vobVelocity = 0 then
  1564                         if vobVelocity = 0 then
  1598                             DrawSprite(sprFlake, x, y, Gear^.Timer)
  1565                             DrawSprite(sprFlake, x, y, Gear^.Timer)
  1599                         else
  1566                         else
  1600                             DrawSpriteRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle);
  1567                             DrawSpriteRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle);
  1601 //DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer)
       
  1602 //DrawSpriteRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle);
       
  1603                         if Gear^.FlightTime > 0 then
  1568                         if Gear^.FlightTime > 0 then
  1604                             untint;
  1569                             untint;
  1605                         end;
  1570                         end;
  1606           gtTardis: if Gear^.Pos <> 4 then
  1571           gtTardis: if Gear^.Pos <> 4 then
  1607                         begin
  1572                         begin
  1615                         else
  1580                         else
  1616                             Tint($FF,$FF,$FF,max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
  1581                             Tint($FF,$FF,$FF,max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000)))));
  1617                         DrawSprite(sprTardis, x-25, y-64,1);
  1582                         DrawSprite(sprTardis, x-25, y-64,1);
  1618                         if Gear^.Pos <> 2 then
  1583                         if Gear^.Pos <> 2 then
  1619                             untint
  1584                             untint
  1620 (*
       
  1621                         Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * abs(1 - (RealTicks mod 500) / 250))));
       
  1622                         DrawTexture(x-6, y-70, SpritesData[sprVampiric].Texture, 0.25);
       
  1623                         untint
       
  1624 *)
       
  1625                         end;
  1585                         end;
  1626             gtIceGun: begin
  1586             gtIceGun: begin
  1627                       HHGear := Gear^.Hedgehog^.Gear;
  1587                       HHGear := Gear^.Hedgehog^.Gear;
  1628                       if HHGear <> nil then
  1588                       if HHGear <> nil then
  1629                           begin
  1589                           begin