hedgewars/uGearsRender.pas
changeset 15024 af2f6f4074de
parent 14998 39dd40aca1b1
child 15035 a315927a44b2
equal deleted inserted replaced
15023:9a8c678df7d9 15024:af2f6f4074de
    93     EnableTexture(true);
    93     EnableTexture(true);
    94     end
    94     end
    95 end;
    95 end;
    96 
    96 
    97 
    97 
    98 function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt): LongInt;
    98 function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt; LayerIndex: Longword): LongInt;
    99 var  eX, eY, dX, dY: LongInt;
    99 var  eX, eY, dX, dY: LongInt;
   100     i, sX, sY, x, y, d: LongInt;
   100     i, sX, sY, x, y, d: LongInt;
   101     b: boolean;
   101     b: boolean;
   102     angle: real;
   102     angle: real;
   103 begin
   103 begin
   160             b:= true
   160             b:= true
   161             end;
   161             end;
   162         if b then
   162         if b then
   163             begin
   163             begin
   164             inc(roplen);
   164             inc(roplen);
   165             if (roplen mod cRopeNodeStep) = 0 then
   165             if (roplen mod (cRopeNodeStep * cRopeLayers)) = (cRopeNodeStep * LayerIndex) then
   166                 DrawSpriteRotatedF(sprRopeNode, x, y, roplen div cRopeNodeStep, 1, angle);
   166                 DrawSpriteRotatedF(sprRopeNode, x, y, roplen div cRopeNodeStep, 1, angle);
   167             end
   167             end
   168     end;
   168     end;
   169     DrawRopeLine:= roplen;
   169     DrawRopeLine:= roplen;
   170 end;
   170 end;
   171 
   171 
       
   172 procedure DrawRopeLayer(Gear: PGear; LayerIndex: LongWord);
       
   173 var roplen, i: LongInt;
       
   174 begin
       
   175     roplen:= 0;
       
   176     if RopePoints.Count > 0 then
       
   177     begin
       
   178         i:= 0;
       
   179         while i < Pred(RopePoints.Count) do
       
   180         begin
       
   181             roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
       
   182                                   hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy, roplen, LayerIndex);
       
   183             inc(i)
       
   184         end;
       
   185         roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
       
   186                               hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, roplen, LayerIndex);
       
   187         roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
       
   188                               hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen, LayerIndex);
       
   189     end
       
   190     else
       
   191         if Gear^.Elasticity.QWordValue > 0 then
       
   192             roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
       
   193                                   hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen, LayerIndex);
       
   194 end;
       
   195 
   172 procedure DrawRope(Gear: PGear);
   196 procedure DrawRope(Gear: PGear);
   173 var roplen, i: LongInt;
   197 var i: LongInt;
   174 begin
   198 begin
   175     if Gear^.Hedgehog^.Gear = nil then exit;
   199     if Gear^.Hedgehog^.Gear = nil then exit;
   176     if (Gear^.Tag = 1) or ((cReducedQuality and rqSimpleRope) <> 0) then
   200     if (Gear^.Tag = 1) or ((cReducedQuality and rqSimpleRope) <> 0) then
   177         DrawRopeLinesRQ(Gear)
   201         DrawRopeLinesRQ(Gear)
   178     else
   202     else
   179         begin
   203         for i := 0 to cRopeLayers - 1 do
   180         roplen:= 0;
   204             DrawRopeLayer(Gear, i);
   181         if RopePoints.Count > 0 then
       
   182             begin
       
   183             i:= 0;
       
   184             while i < Pred(RopePoints.Count) do
       
   185                     begin
       
   186                     roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
       
   187                                 hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy, roplen);
       
   188                     inc(i)
       
   189                     end;
       
   190             roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
       
   191                         hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, roplen);
       
   192             roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
       
   193                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen);
       
   194             end
       
   195         else
       
   196             if Gear^.Elasticity.QWordValue > 0 then
       
   197             roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
       
   198                         hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen);
       
   199         end;
       
   200 
       
   201 
   205 
   202 if RopePoints.Count > 0 then
   206 if RopePoints.Count > 0 then
   203     DrawSpriteRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle)
   207     DrawSpriteRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle)
   204 else
   208 else
   205     if Gear^.Elasticity.QWordValue > 0 then
   209     if Gear^.Elasticity.QWordValue > 0 then