hedgewars/uGears.pas
changeset 3032 9c190d3c165b
parent 3030 411146650700
child 3038 4e48c276a468
equal deleted inserted replaced
3031:542444bfe37d 3032:9c190d3c165b
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uGears;
    21 unit uGears;
    22 interface
    22 interface
    23 uses SDLh, uConsts, uFloat;
    23 uses SDLh, uConsts, uFloat, Math;
    24 
    24 
    25     
    25     
    26 type
    26 type
    27     PGear = ^TGear;
    27     PGear = ^TGear;
    28     TGearStepProcedure = procedure (Gear: PGear);
    28     TGearStepProcedure = procedure (Gear: PGear);
   180             @doStepRCPlane,
   180             @doStepRCPlane,
   181             @doStepSniperRifleShot,
   181             @doStepSniperRifleShot,
   182             @doStepJetpack,
   182             @doStepJetpack,
   183             @doStepMolotov,
   183             @doStepMolotov,
   184             @doStepCase,
   184             @doStepCase,
   185             @doStepBirdy
   185             @doStepBirdy,
       
   186             @doStepBigExplosion
   186             );
   187             );
   187 
   188 
   188 procedure InsertGearToList(Gear: PGear);
   189 procedure InsertGearToList(Gear: PGear);
   189 var tmp, ptmp: PGear;
   190 var tmp, ptmp: PGear;
   190 begin
   191 begin
   440                 end;
   441                 end;
   441        gtBirdy: begin
   442        gtBirdy: begin
   442                 gear^.Radius:= 16; // todo: check
   443                 gear^.Radius:= 16; // todo: check
   443                 gear^.Timer:= 500;
   444                 gear^.Timer:= 500;
   444                 gear^.Health:= 2000;
   445                 gear^.Health:= 2000;
       
   446                 end;
       
   447 gtBigExplosion: begin
       
   448                 gear^.X:= gear^.X;
       
   449                 gear^.Y:= gear^.Y;
       
   450                 gear^.Angle:= random(360);
   445                 end;
   451                 end;
   446      end;
   452      end;
   447 InsertGearToList(gear);
   453 InsertGearToList(gear);
   448 AddGear:= gear;
   454 AddGear:= gear;
   449 
   455 
  1659       gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle);
  1665       gtWatermelon: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 0, Gear^.DirAngle);
  1660       gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle);
  1666       gtMelonPiece: DrawRotatedf(sprWatermelon, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 1, 0, Gear^.DirAngle);
  1661      gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1667      gtHellishBomb: DrawRotated(sprHellishBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1662       gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
  1668       gtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State);
  1663            gtBirdy: DrawTextureF(SpritesData[sprBirdy].Texture, 1 - Gear^.Timer / 500, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
  1669            gtBirdy: DrawTextureF(SpritesData[sprBirdy].Texture, 1 - Gear^.Timer / 500, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
       
  1670     gtBigExplosion: begin
       
  1671                     glColor4f(1, 1, 1, 1.0 * (power(2, -5 * (Gear^.Timer-200)/200)));
       
  1672                     DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -4 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
       
  1673                     glColor4f(1, 1, 1, 1);
       
  1674                     end;
  1664          end;
  1675          end;
  1665       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(hwRound(Gear^.X) + 8 + WorldDx, hwRound(Gear^.Y) + 8 + WorldDy, Gear^.Tex);
  1676       if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(hwRound(Gear^.X) + 8 + WorldDx, hwRound(Gear^.Y) + 8 + WorldDy, Gear^.Tex);
  1666       Gear:= Gear^.NextGear
  1677       Gear:= Gear^.NextGear
  1667       end;
  1678       end;
  1668 end;
  1679 end;
  1735 var Gear: PGear;
  1746 var Gear: PGear;
  1736     dmg, dmgRadius: LongInt;
  1747     dmg, dmgRadius: LongInt;
  1737 begin
  1748 begin
  1738 TargetPoint.X:= NoPointX;
  1749 TargetPoint.X:= NoPointX;
  1739 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1750 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1740 if (Radius > 10) and ((Mask and EXPLNoGfx) = 0) then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
  1751 if ((Mask and EXPLNoGfx) = 0) then
       
  1752     begin
       
  1753     if Radius > 50 then AddGear(X, Y, gtBigExplosion, 0, _0, _0, 0)
       
  1754     else if Radius > 10 then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
       
  1755     end;
  1741 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
  1756 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
  1742 
  1757 
  1743 if (Mask and EXPLAllDamageInRadius) = 0 then
  1758 if (Mask and EXPLAllDamageInRadius) = 0 then
  1744     dmgRadius:= Radius shl 1
  1759     dmgRadius:= Radius shl 1
  1745 else
  1760 else