hedgewars/uGearsRender.pas
changeset 10015 4feced261c68
parent 10001 ec523563826e
parent 9950 2759212a27de
child 10040 4ac87acbaed9
equal deleted inserted replaced
10014:56d2f2d5aad8 10015:4feced261c68
    21 unit uGearsRender;
    21 unit uGearsRender;
    22 
    22 
    23 interface
    23 interface
    24 uses uTypes, uConsts, GLunit, uFloat, SDLh;
    24 uses uTypes, uConsts, GLunit, uFloat, SDLh;
    25 
    25 
       
    26 type
       
    27    Tar = record
       
    28             X, Y: hwFloat;
       
    29             dLen: hwFloat;
       
    30             b : boolean;
       
    31          end;
       
    32    TRopePoints = record
       
    33             Count     : Longword;
       
    34             HookAngle : GLfloat;
       
    35             ar        : array[0..MAXROPEPOINTS] of Tar;
       
    36             rounded   : array[0..MAXROPEPOINTS + 2] of TVertex2f;
       
    37          end;
    26 procedure RenderGear(Gear: PGear; x, y: LongInt);
    38 procedure RenderGear(Gear: PGear; x, y: LongInt);
    27 
    39 
    28 var RopePoints: record
    40 var RopePoints: record
    29                 Count: Longword;
    41                 Count: Longword;
    30                 HookAngle: GLfloat;
    42                 HookAngle: GLfloat;
    81     b: boolean;
    93     b: boolean;
    82 begin
    94 begin
    83     if (X1 = X2) and (Y1 = Y2) then
    95     if (X1 = X2) and (Y1 = Y2) then
    84         begin
    96         begin
    85         //OutError('WARNING: zero length rope line!', false);
    97         //OutError('WARNING: zero length rope line!', false);
       
    98         DrawRopeLine:= 0;
    86         exit
    99         exit
    87         end;
   100         end;
    88     eX:= 0;
   101     eX:= 0;
    89     eY:= 0;
   102     eY:= 0;
    90     dX:= X2 - X1;
   103     dX:= X2 - X1;
   141             inc(roplen);
   154             inc(roplen);
   142             if (roplen mod 4) = 0 then
   155             if (roplen mod 4) = 0 then
   143                 DrawSprite(sprRopeNode, x - 2, y - 2, 0)
   156                 DrawSprite(sprRopeNode, x - 2, y - 2, 0)
   144             end
   157             end
   145     end;
   158     end;
   146 DrawRopeLine:= roplen;
   159     DrawRopeLine:= roplen;
   147 end;
   160 end;
   148 
   161 
   149 procedure DrawRope(Gear: PGear);
   162 procedure DrawRope(Gear: PGear);
   150 var roplen: LongInt;
   163 var roplen: LongInt;
   151     i: Longword;
   164     i: Longword;
  1266                         end
  1279                         end
  1267                     else //if not isInLag then
  1280                     else //if not isInLag then
  1268                         begin
  1281                         begin
  1269                         if isInLag and (Gear^.FlightTime < 256) then
  1282                         if isInLag and (Gear^.FlightTime < 256) then
  1270                             inc(Gear^.FlightTime, 8)
  1283                             inc(Gear^.FlightTime, 8)
  1271                         else if not isInLag and (Gear^.FlightTime > 0) then
  1284                         else if (not isInLag) and (Gear^.FlightTime > 0) then
  1272                             dec(Gear^.FlightTime, 8);
  1285                             dec(Gear^.FlightTime, 8);
  1273                         if Gear^.FlightTime > 0 then
  1286                         if Gear^.FlightTime > 0 then
  1274                             Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime));
  1287                             Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime));
  1275                         if vobVelocity = 0 then
  1288                         if vobVelocity = 0 then
  1276                             DrawSprite(sprFlake, x, y, Gear^.Timer)
  1289                             DrawSprite(sprFlake, x, y, Gear^.Timer)