hedgewars/uGearsRender.pas
changeset 10443 42dadeb6e8ae
parent 10441 d2f599997b54
child 10523 00ac079fa51f
equal deleted inserted replaced
10441:d2f599997b54 10443:42dadeb6e8ae
     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  *
     9  * This program is distributed in the hope that it will be useful,
     9 	 * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    12  * GNU General Public License for more details.
    13  *
    13  *
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
   217     defaultPos, HatVisible: boolean;
   217     defaultPos, HatVisible: boolean;
   218     HH: PHedgehog;
   218     HH: PHedgehog;
   219     CurWeapon: PAmmo;
   219     CurWeapon: PAmmo;
   220     iceOffset:Longint;
   220     iceOffset:Longint;
   221     r:TSDL_Rect;
   221     r:TSDL_Rect;
       
   222     curhat: PTexture;
   222 begin
   223 begin
   223     HH:= Gear^.Hedgehog;
   224     HH:= Gear^.Hedgehog;
   224     if HH^.Unplaced then
   225     if HH^.Unplaced then
   225         exit;
   226         exit;
       
   227     if (HH^.CurAmmoType = amKnife) and (HH = CurrentHedgehog) then
       
   228          curhat:= ChefHatTexture
       
   229     else curhat:= HH^.HatTex;
   226     m:= 1;
   230     m:= 1;
   227     if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then
   231     if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then
   228         m:= -1;
   232         m:= -1;
   229     sx:= ox + 1; // this offset is very common
   233     sx:= ox + 1; // this offset is very common
   230     sy:= oy - 3;
   234     sy:= oy - 3;
   429                                 i,
   433                                 i,
   430                                 1,
   434                                 1,
   431                                 0,
   435                                 0,
   432                                 DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   436                                 DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   433                         with HH^ do
   437                         with HH^ do
   434                             if (HatTex <> nil) then
   438                             if (curhat <> nil) then
   435                                 begin
   439                                 begin
   436                                 DrawTextureRotatedF(HatTex, 1.0, -1.0, -6.0, ox, oy, 0, i, 32, 32,
   440                                 DrawTextureRotatedF(curhat, 1.0, -1.0, -6.0, ox, oy, 0, i, 32, 32,
   437                                     i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   441                                     i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   438                                 if HatTex^.w > 64 then
   442                                 if curhat^.w > 64 then
   439                                     begin
   443                                     begin
   440                                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   444                                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   441                                     DrawTextureRotatedF(HatTex, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32,
   445                                     DrawTextureRotatedF(curhat, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32,
   442                                         i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   446                                         i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   443                                     untint
   447                                     untint
   444                                     end
   448                                     end
   445                                 end
   449                                 end
   446                     end;
   450                     end;
   454                             sign,
   458                             sign,
   455                             3,
   459                             3,
   456                             HH^.visStepPos div 2,
   460                             HH^.visStepPos div 2,
   457                             0);
   461                             0);
   458                     with HH^ do
   462                     with HH^ do
   459                         if (HatTex <> nil) then
   463                         if (curhat <> nil) then
   460                             begin
   464                             begin
   461                             DrawTextureF(HatTex,
   465                             DrawTextureF(curhat,
   462                                 1,
   466                                 1,
   463                                 sx,
   467                                 sx,
   464                                 sy - 5,
   468                                 sy - 5,
   465                                 0,
   469                                 0,
   466                                 sign,
   470                                 sign,
   467                                 32,
   471                                 32,
   468                                 32);
   472                                 32);
   469                             if HatTex^.w > 64 then
   473                             if curhat^.w > 64 then
   470                                 begin
   474                                 begin
   471                                 Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   475                                 Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   472                                 DrawTextureF(HatTex,
   476                                 DrawTextureF(curhat,
   473                                     1,
   477                                     1,
   474                                     sx,
   478                                     sx,
   475                                     sy - 5,
   479                                     sy - 5,
   476                                     32,
   480                                     32,
   477                                     sign,
   481                                     sign,
   826             else
   830             else
   827         else
   831         else
   828             if HatVisibility > 0.0 then
   832             if HatVisibility > 0.0 then
   829                 HatVisibility:= HatVisibility - 0.2;
   833                 HatVisibility:= HatVisibility - 0.2;
   830 
   834 
   831         if (HatTex <> nil)
   835         if (curhat <> nil)
   832         and (HatVisibility > 0) then
   836         and (HatVisibility > 0) then
   833             if DefaultPos then
   837             if DefaultPos then
   834                 begin
   838                 begin
   835                 DrawTextureF(HatTex,
   839                 DrawTextureF(curhat,
   836                     HatVisibility,
   840                     HatVisibility,
   837                     sx,
   841                     sx,
   838                     sy - 5,
   842                     sy - 5,
   839                     (RealTicks div 128 + Gear^.Pos) mod 19,
   843                     (RealTicks div 128 + Gear^.Pos) mod 19,
   840                     sign,
   844                     sign,
   841                     32,
   845                     32,
   842                     32);
   846                     32);
   843                 if HatTex^.w > 64 then
   847                 if curhat^.w > 64 then
   844                     begin
   848                     begin
   845                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   849                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   846                     DrawTextureF(HatTex,
   850                     DrawTextureF(curhat,
   847                         HatVisibility,
   851                         HatVisibility,
   848                         sx,
   852                         sx,
   849                         sy - 5,
   853                         sy - 5,
   850                         (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
   854                         (RealTicks div 128 + Gear^.Pos) mod 19 + 32,
   851                         sign,
   855                         sign,
   855                     end;
   859                     end;
   856                 if HH^.Team^.hasGone then untint
   860                 if HH^.Team^.hasGone then untint
   857                 end
   861                 end
   858             else
   862             else
   859                 begin
   863                 begin
   860                 DrawTextureF(HatTex,
   864                 DrawTextureF(curhat,
   861                     HatVisibility,
   865                     HatVisibility,
   862                     sx,
   866                     sx,
   863                     sy - 5,
   867                     sy - 5,
   864                     0,
   868                     0,
   865                     sign*m,
   869                     sign*m,
   866                     32,
   870                     32,
   867                     32);
   871                     32);
   868                 if HatTex^.w > 64 then
   872                 if curhat^.w > 64 then
   869                     begin
   873                     begin
   870                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   874                     Tint(HH^.Team^.Clan^.Color shl 8 or $FF);
   871                     DrawTextureF(HatTex,
   875                     DrawTextureF(curhat,
   872                         HatVisibility,
   876                         HatVisibility,
   873                         sx,
   877                         sx,
   874                         sy - 5,
   878                         sy - 5,
   875                         32,
   879                         32,
   876                         sign*m,
   880                         sign*m,