hedgewars/uGearsRender.pas
branchqmlfrontend
changeset 10606 8e95911cb86b
parent 10562 3388822b3914
child 10682 1be106f8095a
equal deleted inserted replaced
10519:af019fa70080 10606:8e95911cb86b
    51 
    51 
    52 implementation
    52 implementation
    53 uses uRender, uUtils, uVariables, uAmmos, Math, uVisualGearsList;
    53 uses uRender, uUtils, uVariables, uAmmos, Math, uVisualGearsList;
    54 
    54 
    55 procedure DrawRopeLinesRQ(Gear: PGear);
    55 procedure DrawRopeLinesRQ(Gear: PGear);
       
    56 var n: LongInt;
    56 begin
    57 begin
    57 with RopePoints do
    58 with RopePoints do
    58     begin
    59     begin
    59     rounded[Count].X:= hwRound(Gear^.X);
    60     rounded[Count].X:= hwRound(Gear^.X);
    60     rounded[Count].Y:= hwRound(Gear^.Y);
    61     rounded[Count].Y:= hwRound(Gear^.Y);
    62     rounded[Count + 1].Y:= hwRound(Gear^.Hedgehog^.Gear^.Y);
    63     rounded[Count + 1].Y:= hwRound(Gear^.Hedgehog^.Gear^.Y);
    63     end;
    64     end;
    64 
    65 
    65 if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then
    66 if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then
    66     begin
    67     begin
    67     glDisable(GL_TEXTURE_2D);
    68     EnableTexture(false);
    68     //glEnable(GL_LINE_SMOOTH);
    69     //glEnable(GL_LINE_SMOOTH);
    69 
    70 
    70     glPushMatrix;
    71     Tint($70, $70, $70, $FF);
    71 
    72 
    72     glTranslatef(WorldDx, WorldDy, 0);
    73     n:= RopePoints.Count + 2;
    73 
    74 
       
    75     SetVertexPointer(@RopePoints.rounded[0], n);
       
    76 
       
    77     openglPushMatrix();
       
    78     openglTranslatef(WorldDx, WorldDy, 0);
       
    79 
       
    80     glLineWidth(3.0 * cScaleFactor);
       
    81     glDrawArrays(GL_LINE_STRIP, 0, n);
       
    82     Tint($D8, $D8, $D8, $FF);
    74     glLineWidth(2.0 * cScaleFactor);
    83     glLineWidth(2.0 * cScaleFactor);
    75 
    84     glDrawArrays(GL_LINE_STRIP, 0, n);
    76     Tint($C0, $C0, $C0, $FF);
    85 
    77 
       
    78     glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]);
       
    79     glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2);
       
    80     untint;
    86     untint;
    81 
    87 
    82     glPopMatrix;
    88     openglPopMatrix();
    83 
    89 
    84     glEnable(GL_TEXTURE_2D);
    90     EnableTexture(true);
    85     //glDisable(GL_LINE_SMOOTH)
    91     //glDisable(GL_LINE_SMOOTH)
    86     end
    92     end
    87 end;
    93 end;
    88 
    94 
    89 
    95 
   158     end;
   164     end;
   159     DrawRopeLine:= roplen;
   165     DrawRopeLine:= roplen;
   160 end;
   166 end;
   161 
   167 
   162 procedure DrawRope(Gear: PGear);
   168 procedure DrawRope(Gear: PGear);
   163 var roplen: LongInt;
   169 var roplen, i: LongInt;
   164     i: Longword;
       
   165 begin
   170 begin
   166     if (cReducedQuality and rqSimpleRope) <> 0 then
   171     if (cReducedQuality and rqSimpleRope) <> 0 then
   167         DrawRopeLinesRQ(Gear)
   172         DrawRopeLinesRQ(Gear)
   168     else
   173     else
   169         begin
   174         begin
   616             end
   621             end
   617         else
   622         else
   618 
   623 
   619         if ((Gear^.State and gstAnimation) <> 0) then
   624         if ((Gear^.State and gstAnimation) <> 0) then
   620             begin
   625             begin
   621             if (TWave(Gear^.Tag) < Low(TWave)) or (TWave(Gear^.Tag) > High(TWave)) then
   626             if (Gear^.Tag < LongInt(ord(Low(TWave)))) or (Gear^.Tag > LongInt(ord(High(TWave)))) then
   622                 begin
   627                 begin
   623                 Gear^.State:= Gear^.State and (not gstAnimation);
   628                 Gear^.State:= Gear^.State and (not gstAnimation);
   624                 end
   629                 end
   625             else
   630             else
   626                 begin
   631                 begin
   703                                             oy-256,
   708                                             oy-256,
   704                                             LongInt(topY)+WorldDy,
   709                                             LongInt(topY)+WorldDy,
   705                                             LongInt(rightX)+WorldDx,
   710                                             LongInt(rightX)+WorldDx,
   706                                             cWaterLine+WorldDy,
   711                                             cWaterLine+WorldDy,
   707                                             LongInt(leftX)+WorldDx);
   712                                             LongInt(leftX)+WorldDx);
   708                         if hwRound(Gear^.X) > rightX-256 then
   713                         if hwRound(Gear^.X) > LongInt(rightX) - 256 then
   709                             DrawSpriteClipped(sprGirder,
   714                             DrawSpriteClipped(sprGirder,
   710                                             leftX-(rightX-ox)-256,
   715                                             leftX-(rightX-ox)-256,
   711                                             oy-256,
   716                                             oy-256,
   712                                             LongInt(topY)+WorldDy,
   717                                             LongInt(topY)+WorldDy,
   713                                             LongInt(rightX)+WorldDx,
   718                                             LongInt(rightX)+WorldDx,
   789     end else // not gstHHDriven
   794     end else // not gstHHDriven
   790         begin
   795         begin
   791         if (Gear^.Damage > 0) and (HH^.Effects[heFrozen] = 0)
   796         if (Gear^.Damage > 0) and (HH^.Effects[heFrozen] = 0)
   792         and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   797         and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   793             begin
   798             begin
   794             DrawHedgehog(sx, sy,
   799             defaultPos:= false;
   795                 sign,
   800                 DrawHedgehog(sx, sy,
   796                 2,
   801                     sign,
   797                 1,
   802                     2,
   798                 Gear^.DirAngle);
   803                     1,
   799             defaultPos:= false
   804                     Gear^.DirAngle);
   800             end else
   805             if AprilOne and (curhat <> nil) then
       
   806                 DrawTextureRotatedF(curhat, 1.0, -1.0, 0, sx, sy, 18, sign, 32, 32,
       
   807                     sign*Gear^.DirAngle)
       
   808             end;
       
   809 
   801 
   810 
   802         if ((Gear^.State and gstHHJumping) <> 0) then
   811         if ((Gear^.State and gstHHJumping) <> 0) then
   803             begin
   812             begin
   804             DrawHedgehog(sx, sy,
   813             DrawHedgehog(sx, sy,
   805                 sign*m,
   814                 sign*m,
  1155                                 end
  1164                                 end
  1156                             end
  1165                             end
  1157                         end;
  1166                         end;
  1158                     if Gear^.Timer < 1833 then
  1167                     if Gear^.Timer < 1833 then
  1159                         begin
  1168                         begin
  1160                         DrawTextureRotatedF(SpritesData[sprPortal].texture, min(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0,
  1169                         DrawTextureRotatedF(SpritesData[sprPortal].texture, MinD(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0,
  1161                                             x, LongInt(Gear^.Angle) + WorldDy - 16, 4 + Gear^.Tag, 1, 32, 32, 270);
  1170                                             x, LongInt(Gear^.Angle) + WorldDy - 16, 4 + Gear^.Tag, 1, 32, 32, 270);
  1162                         end
  1171                         end
  1163                     end;
  1172                     end;
  1164       gtExplosives: begin
  1173       gtExplosives: begin
  1165                     if ((Gear^.State and gstDrowning) <> 0) then
  1174                     if ((Gear^.State and gstDrowning) <> 0) then
  1193                     DrawSpriteRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0);
  1202                     DrawSpriteRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0);
  1194                     end;
  1203                     end;
  1195          gtAirBomb: DrawSpriteRotated(sprAirBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1204          gtAirBomb: DrawSpriteRotated(sprAirBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1196         gtTeleport: begin
  1205         gtTeleport: begin
  1197                     HHGear:= Gear^.Hedgehog^.Gear;
  1206                     HHGear:= Gear^.Hedgehog^.Gear;
  1198                     if not Gear^.Hedgehog^.Unplaced then
  1207                     if ((Gear^.State and gstAnimation) <> 0) then
  1199                         DrawSpriteRotatedF(sprTeleport, x + 1, y - 3, Gear^.Pos, hwSign(Gear^.dX), 0);
  1208                         DrawSpriteRotatedF(sprTeleport, x + 1, y - 3, Gear^.Pos, hwSign(Gear^.dX), 0);
  1200                     DrawSpriteRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
  1209                     DrawSpriteRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0);
  1201                     end;
  1210                     end;
  1202         gtSwitcher: DrawSprite(sprSwitch, x - 16, y - 56, (GameTicks shr 6) mod 12);
  1211         gtSwitcher: DrawSprite(sprSwitch, x - 16, y - 56, (GameTicks shr 6) mod 12);
  1203           gtTarget: begin
  1212           gtTarget: begin