hedgewars/uGearsRender.pas
branchwebgl
changeset 9127 e350500c4edb
parent 8833 c13ebed437cb
parent 9080 9b42757d7e71
child 9521 8054d9d775fd
equal deleted inserted replaced
8860:bde641cf53c8 9127:e350500c4edb
     1 (*
     1 (*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
   363                     (Land[ty, tx] = 0) do // TODO: check for constant variable instead
   363                     (Land[ty, tx] = 0) do // TODO: check for constant variable instead
   364                     begin
   364                     begin
   365                     lx:= lx + ax;
   365                     lx:= lx + ax;
   366                     ly:= ly + ay;
   366                     ly:= ly + ay;
   367                     tx:= round(lx);
   367                     tx:= round(lx);
   368                     ty:= round(ly);
   368                     ty:= round(ly)
   369                     if (abs(tx-hx) > 1000) or (abs(hy-ty) > 1000) then
       
   370                         begin
       
   371                         DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0);
       
   372                         hx:= tx;
       
   373                         hy:= ty
       
   374                         end
       
   375                     end;
   369                     end;
   376                 // reached edge of land. assume infinite beam. Extend it way out past camera
   370                 // reached edge of land. assume infinite beam. Extend it way out past camera
   377                 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
   371                 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
   378                     begin
   372                     begin
   379                     tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
   373                     tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
   380                     ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
   374                     ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
   381                     end;
   375                     end;
   382 
   376 
   383                 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
   377                 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
   384                 if (tx <> hx) or (ty <> hy) then
       
   385                     begin
   378                     begin
   386                     DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0);
   379                     DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0);
   387                     end;
   380                     end;
   388                 end;
   381                 end;
   389             // draw crosshair
   382             // draw crosshair
   997     vg: PVisualGear;
   990     vg: PVisualGear;
   998     i: Longword;
   991     i: Longword;
   999     aAngle: real;
   992     aAngle: real;
  1000     startX, endX, startY, endY: LongInt;
   993     startX, endX, startY, endY: LongInt;
  1001 begin
   994 begin
       
   995     if Gear^.State and gstFrozen <> 0 then Tint($A0, $A0, $FF, $FF);
       
   996     //if Gear^.State and gstFrozen <> 0 then Tint(IceColor or $FF);
  1002     if Gear^.Target.X <> NoPointX then
   997     if Gear^.Target.X <> NoPointX then
  1003         if Gear^.AmmoType = amBee then
   998         if Gear^.AmmoType = amBee then
  1004             DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
   999             DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
  1005     else if Gear^.AmmoType = amIceGun then
  1000     else if Gear^.AmmoType = amIceGun then
  1006         //DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8)
  1001         //DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8)
  1056                     end;
  1051                     end;
  1057              gtBee: DrawSpriteRotatedF(sprBee, x, y, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1052              gtBee: DrawSpriteRotatedF(sprBee, x, y, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1058       gtPickHammer: DrawSprite(sprPHammer, x - 16, y - 50 + LongInt(((GameTicks shr 5) and 1) * 2), 0);
  1053       gtPickHammer: DrawSprite(sprPHammer, x - 16, y - 50 + LongInt(((GameTicks shr 5) and 1) * 2), 0);
  1059             gtRope: DrawRope(Gear);
  1054             gtRope: DrawRope(Gear);
  1060 
  1055 
  1061             gtMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
  1056             gtMine: begin
       
  1057                     if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
  1062                            DrawSpriteRotated(sprMineOff, x, y, 0, Gear^.DirAngle)
  1058                            DrawSpriteRotated(sprMineOff, x, y, 0, Gear^.DirAngle)
  1063                        else if Gear^.Health <> 0 then
  1059                     else if Gear^.Health <> 0 then
  1064                            DrawSpriteRotated(sprMineOn, x, y, 0, Gear^.DirAngle)
  1060                        DrawSpriteRotated(sprMineOn, x, y, 0, Gear^.DirAngle)
  1065                        else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
  1061                     else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
       
  1062                     end;
  1066 
  1063 
  1067            gtSMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
  1064            gtSMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
  1068                            DrawSpriteRotated(sprSMineOff, x, y, 0, Gear^.DirAngle)
  1065                            DrawSpriteRotated(sprSMineOff, x, y, 0, Gear^.DirAngle)
  1069                        else if Gear^.Health <> 0 then
  1066                        else if Gear^.Health <> 0 then
  1070                            DrawSpriteRotated(sprSMineOn, x, y, 0, Gear^.DirAngle)
  1067                            DrawSpriteRotated(sprSMineOn, x, y, 0, Gear^.DirAngle)
  1074             gtCase: begin
  1071             gtCase: begin
  1075                     if Gear^.Timer > 1000 then
  1072                     if Gear^.Timer > 1000 then
  1076                         begin
  1073                         begin
  1077                         if ((Gear^.Pos and posCaseAmmo) <> 0) then
  1074                         if ((Gear^.Pos and posCaseAmmo) <> 0) then
  1078                             begin
  1075                             begin
  1079                             i:= (GameTicks shr 6) mod 64;
  1076                             if Gear^.State and gstFrozen <> 0 then
  1080                             if i > 18 then
  1077                                 DrawSprite(sprCase, x - 24, y - 28, 0)
  1081                                 i:= 0;
  1078                             else
  1082                             DrawSprite(sprCase, x - 24, y - 24, i);
  1079                                 begin
       
  1080                                 i:= (GameTicks shr 6) mod 64;
       
  1081                                 if i > 18 then i:= 0;
       
  1082                                 DrawSprite(sprCase, x - 24, y - 24, i)
       
  1083                                 end
  1083                             end
  1084                             end
  1084                         else if ((Gear^.Pos and posCaseHealth) <> 0) then
  1085                         else if ((Gear^.Pos and posCaseHealth) <> 0) then
  1085                             begin
  1086                             begin
  1086                             i:= ((GameTicks shr 6) + 38) mod 64;
  1087                             if Gear^.State and gstFrozen <> 0 then
  1087                             if i > 13 then
  1088                                 DrawSprite(sprFAid, x - 24, y - 28, 0)
  1088                                 i:= 0;
  1089                             else
  1089                             DrawSprite(sprFAid, x - 24, y - 24, i);
  1090                                 begin
       
  1091                                 i:= ((GameTicks shr 6) + 38) mod 64;
       
  1092                                 if i > 13 then i:= 0;
       
  1093                                 DrawSprite(sprFAid, x - 24, y - 24, i)
       
  1094                                 end
  1090                             end
  1095                             end
  1091                         else if ((Gear^.Pos and posCaseUtility) <> 0) then
  1096                         else if ((Gear^.Pos and posCaseUtility) <> 0) then
  1092                             begin
  1097                             begin
  1093                             i:= (GameTicks shr 6) mod 70;
  1098                             if Gear^.State and gstFrozen <> 0 then
  1094                             if i > 23 then
  1099                                 DrawSprite(sprUtility, x - 24, y - 28, 0)
  1095                                 i:= 0;
  1100                             else
  1096                             i:= i mod 12;
  1101                                 begin
  1097                             DrawSprite(sprUtility, x - 24, y - 24, i);
  1102                                 i:= (GameTicks shr 6) mod 70;
  1098                             end;
  1103                                 if i > 23 then i:= 0;
       
  1104                                 i:= i mod 12;
       
  1105                                 DrawSprite(sprUtility, x - 24, y - 24, i)
       
  1106                                 end
       
  1107                             end
  1099                         end;
  1108                         end;
  1100                     if Gear^.Timer < 1833 then
  1109                     if Gear^.Timer < 1833 then
  1101                         begin
  1110                         begin
  1102                         DrawTextureRotatedF(SpritesData[sprPortal].texture, min(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0,
  1111                         DrawTextureRotatedF(SpritesData[sprPortal].texture, min(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0,
  1103                                             x, LongInt(Gear^.Angle) + WorldDy - 16, 4 + Gear^.Tag, 1, 32, 32, 270);
  1112                                             x, LongInt(Gear^.Angle) + WorldDy - 16, 4 + Gear^.Tag, 1, 32, 32, 270);
  1114                         DrawSprite(sprExplosives, x - 24, y - 24, i)
  1123                         DrawSprite(sprExplosives, x - 24, y - 24, i)
  1115                         end
  1124                         end
  1116                     else if Gear^.State and gsttmpFlag = 0 then
  1125                     else if Gear^.State and gsttmpFlag = 0 then
  1117                         DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 0, 0, Gear^.DirAngle)
  1126                         DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 0, 0, Gear^.DirAngle)
  1118                     else
  1127                     else
  1119                         DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 1, 0, Gear^.DirAngle);
  1128                         DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 1, 0, Gear^.DirAngle)
  1120                     end;
  1129                     end;
  1121         gtDynamite: DrawSprite(sprDynamite, x - 16, y - 25, Gear^.Tag and 1, Gear^.Tag shr 1);
  1130         gtDynamite: DrawSprite(sprDynamite, x - 16, y - 25, Gear^.Tag and 1, Gear^.Tag shr 1);
  1122      gtClusterBomb: DrawSpriteRotated(sprClusterBomb, x, y, 0, Gear^.DirAngle);
  1131      gtClusterBomb: DrawSpriteRotated(sprClusterBomb, x, y, 0, Gear^.DirAngle);
  1123          gtCluster: DrawSprite(sprClusterParticle, x - 8, y - 8, 0);
  1132          gtCluster: DrawSprite(sprClusterParticle, x - 8, y - 8, 0);
  1124            gtFlame: if Gear^.Tag and 1 = 0 then
  1133            gtFlame: if Gear^.Tag and 1 = 0 then
  1303                       end;
  1312                       end;
  1304             gtGenericFaller: DrawCircle(x, y, 3, 3, $FF, $00, $00, $FF);  // debug
  1313             gtGenericFaller: DrawCircle(x, y, 3, 3, $FF, $00, $00, $FF);  // debug
  1305          end;
  1314          end;
  1306       if Gear^.RenderTimer and (Gear^.Tex <> nil) then
  1315       if Gear^.RenderTimer and (Gear^.Tex <> nil) then
  1307           DrawTextureCentered(x + 8, y + 8, Gear^.Tex);
  1316           DrawTextureCentered(x + 8, y + 8, Gear^.Tex);
       
  1317     if Gear^.State and gstFrozen <> 0 then Tint($FF, $FF, $FF, $FF)
  1308 end;
  1318 end;
  1309 
  1319 
  1310 end.
  1320 end.