hedgewars/GearDrawing.inc
changeset 3836 833c0f32e326
parent 3751 a70c61c076ae
child 3854 d390b0f29b0b
equal deleted inserted replaced
3835:cbee69165c6a 3836:833c0f32e326
     4     hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
     4     hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
     5     dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real;  // laser, change
     5     dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real;  // laser, change
     6     defaultPos, HatVisible: boolean;
     6     defaultPos, HatVisible: boolean;
     7     VertexBuffer: array [0..1] of TVertex2f;
     7     VertexBuffer: array [0..1] of TVertex2f;
     8     HH: PHedgehog;
     8     HH: PHedgehog;
       
     9     CurWeapon: PAmmo;
     9 begin
    10 begin
    10 HH:= PHedgehog(Gear^.Hedgehog);
    11 HH:= PHedgehog(Gear^.Hedgehog);
    11 if HH^.Unplaced then exit;
    12 if HH^.Unplaced then exit;
    12 m:= 1;
    13 m:= 1;
    13 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
    14 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
    78 *)
    79 *)
    79         dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle);
    80         dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle);
    80         dy:= -Cos(Gear^.Angle * pi / cMaxAngle);
    81         dy:= -Cos(Gear^.Angle * pi / cMaxAngle);
    81         if cLaserSighting then
    82         if cLaserSighting then
    82             begin
    83             begin
    83             lx:= GetLaunchX(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, hwSign(Gear^.dX) * m, Gear^.Angle);
    84             lx:= GetLaunchX(HH^.CurAmmoType, hwSign(Gear^.dX) * m, Gear^.Angle);
    84             ly:= GetLaunchY(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, Gear^.Angle);
    85             ly:= GetLaunchY(HH^.CurAmmoType, Gear^.Angle);
    85 
    86 
    86             // ensure we start outside the hedgehog (he's solid after all)
    87             // ensure we start outside the hedgehog (he's solid after all)
    87             while abs(lx * lx + ly * ly) < (Gear^.radius * Gear^.radius) do
    88             while abs(lx * lx + ly * ly) < (Gear^.radius * Gear^.radius) do
    88                 begin
    89                 begin
    89                 lx:= lx + dx;
    90                 lx:= lx + dx;
   137                 glEnable(GL_TEXTURE_2D);
   138                 glEnable(GL_TEXTURE_2D);
   138                 glDisable(GL_LINE_SMOOTH);
   139                 glDisable(GL_LINE_SMOOTH);
   139                 end;
   140                 end;
   140             end;
   141             end;
   141         // draw crosshair
   142         // draw crosshair
   142         cx:= Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, hwSign(Gear^.dX) * m, Gear^.Angle));
   143         cx:= Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, hwSign(Gear^.dX) * m, Gear^.Angle));
   143         cy:= Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].AmmoType, Gear^.Angle));
   144         cy:= Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
   144         DrawRotatedTex(HH^.Team^.CrosshairTex,
   145         DrawRotatedTex(HH^.Team^.CrosshairTex,
   145                 12, 12, cx + WorldDx, cy + WorldDy, 0,
   146                 12, 12, cx + WorldDx, cy + WorldDy, 0,
   146                 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
   147                 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
   147         end;
   148         end;
   148     hx:= hwRound(Gear^.X) + 8 * hwSign(Gear^.dX) + WorldDx;
   149     hx:= hwRound(Gear^.X) + 8 * hwSign(Gear^.dX) + WorldDx;
   379             if aangle <= 90 then aangle:= aangle+360;
   380             if aangle <= 90 then aangle:= aangle+360;
   380             if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*HH^.Timer/10)
   381             if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*HH^.Timer/10)
   381             else aangle:= aangle+((240-aangle)*HH^.Timer/10);
   382             else aangle:= aangle+((240-aangle)*HH^.Timer/10);
   382             dec(HH^.Timer)
   383             dec(HH^.Timer)
   383             end;
   384             end;
   384         amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
   385         amt:= CurrentHedgehog^.CurAmmoType;
       
   386         CurWeapon:= GetAmmoEntry(HH^);
   385         case amt of
   387         case amt of
   386             amBazooka: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
   388             amBazooka: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
   387             amMortar: DrawRotated(sprHandMortar, hx, hy, hwSign(Gear^.dX), aangle);
   389             amMortar: DrawRotated(sprHandMortar, hx, hy, hwSign(Gear^.dX), aangle);
   388             amMolotov: DrawRotated(sprHandMolotov, hx, hy, hwSign(Gear^.dX), aangle);
   390             amMolotov: DrawRotated(sprHandMolotov, hx, hy, hwSign(Gear^.dX), aangle);
   389             amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   391             amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle);
   390             amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
   392             amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle);
   391             amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
   393             amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
   392             amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   394             amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   393             amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   395             amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   394             amSineGun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   396             amSineGun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   395             amPortalGun: if (HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
   397             amPortalGun: if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
   396                             DrawRotatedF(sprPortalGun, hx, hy, 0, hwSign(Gear^.dX), aangle)
   398                             DrawRotatedF(sprPortalGun, hx, hy, 0, hwSign(Gear^.dX), aangle)
   397                       else
   399                       else
   398                             DrawRotatedF(sprPortalGun, hx, hy, 1+(HH^.Ammo^[HH^.CurSlot, HH^.CurAmmo].Timer and 1), hwSign(Gear^.dX), aangle);
   400                             DrawRotatedF(sprPortalGun, hx, hy, 1+(CurWeapon^.Timer and 1), hwSign(Gear^.dX), aangle);
   399             amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle);
   401             amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle);
   400             amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   402             amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   401             amCake: DrawRotated(sprHandCake, hx, hy, hwSign(Gear^.dX), aangle);
   403             amCake: DrawRotated(sprHandCake, hx, hy, hwSign(Gear^.dX), aangle);
   402             amGrenade: DrawRotated(sprHandGrenade, hx, hy, hwSign(Gear^.dX), aangle);
   404             amGrenade: DrawRotated(sprHandGrenade, hx, hy, hwSign(Gear^.dX), aangle);
   403             amWatermelon: DrawRotated(sprHandMelon, hx, hy, hwSign(Gear^.dX), aangle);
   405             amWatermelon: DrawRotated(sprHandMelon, hx, hy, hwSign(Gear^.dX), aangle);
   582     end;
   584     end;
   583 if (Gear^.State and gstHHDriven) <> 0 then
   585 if (Gear^.State and gstHHDriven) <> 0 then
   584     begin
   586     begin
   585 (*    if (CurAmmoGear = nil) then
   587 (*    if (CurAmmoGear = nil) then
   586         begin
   588         begin
   587         amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
   589         amt:= CurrentHedgehog^.CurAmmoType;
   588         case amt of
   590         case amt of
   589             amJetpack: DrawSprite(sprJetpack, sx-32, sy-32, 0);
   591             amJetpack: DrawSprite(sprJetpack, sx-32, sy-32, 0);
   590             end
   592             end
   591         end; *)
   593         end; *)
   592     if CurAmmoGear <> nil then
   594     if CurAmmoGear <> nil then