hedgewars/uGearsRender.pas
changeset 14944 8b53cb1c0ada
parent 14919 e28ff0f1aca2
child 14949 37ae92c11a36
equal deleted inserted replaced
14943:d01460ae866c 14944:8b53cb1c0ada
    97 
    97 
    98 function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt): LongInt;
    98 function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt): 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 begin
   103 begin
   103     if (X1 = X2) and (Y1 = Y2) then
   104     if (X1 = X2) and (Y1 = Y2) then
   104         begin
   105         begin
   105         //OutError('WARNING: zero length rope line!', false);
   106         //OutError('WARNING: zero length rope line!', false);
   106         DrawRopeLine:= 0;
   107         DrawRopeLine:= 0;
   108         end;
   109         end;
   109     eX:= 0;
   110     eX:= 0;
   110     eY:= 0;
   111     eY:= 0;
   111     dX:= X2 - X1;
   112     dX:= X2 - X1;
   112     dY:= Y2 - Y1;
   113     dY:= Y2 - Y1;
       
   114     angle:= arctan2(dY, dX) * 180 / PI - 90;
   113 
   115 
   114     if (dX > 0) then
   116     if (dX > 0) then
   115         sX:= 1
   117         sX:= 1
   116     else
   118     else
   117         if (dX < 0) then
   119         if (dX < 0) then
   158             b:= true
   160             b:= true
   159             end;
   161             end;
   160         if b then
   162         if b then
   161             begin
   163             begin
   162             inc(roplen);
   164             inc(roplen);
   163             if (roplen mod 4) = 0 then
   165             if (roplen mod cRopeNodeStep) = 0 then
   164                 DrawSprite(sprRopeNode, x - 2, y - 2, 0)
   166                 DrawSpriteRotatedF(sprRopeNode, x, y, roplen mod cRopeNodeStep, 1, angle);
   165             end
   167             end
   166     end;
   168     end;
   167     DrawRopeLine:= roplen;
   169     DrawRopeLine:= roplen;
   168 end;
   170 end;
   169 
   171