hedgewars/GSHandlers.inc
changeset 8945 145bf64a9579
parent 8934 a4ec39eac0be
child 8952 a6ee1e7310fb
equal deleted inserted replaced
8944:ed2509832311 8945:145bf64a9579
   513 
   513 
   514 ////////////////////////////////////////////////////////////////////////////////
   514 ////////////////////////////////////////////////////////////////////////////////
   515 procedure doStepSnowball(Gear: PGear);
   515 procedure doStepSnowball(Gear: PGear);
   516 var kick, i: LongInt;
   516 var kick, i: LongInt;
   517     particle: PVisualGear;
   517     particle: PVisualGear;
       
   518     gdX, gdY: hwFloat;
   518 begin
   519 begin
   519     AllInactive := false;
   520     AllInactive := false;
   520     if (GameFlags and gfMoreWind) = 0 then
   521     if (GameFlags and gfMoreWind) = 0 then
   521         Gear^.dX := Gear^.dX + cWindSpeed;
   522         Gear^.dX := Gear^.dX + cWindSpeed;
       
   523     gdX := Gear^.dX;
       
   524     gdY := Gear^.dY;
   522     doStepFallingGear(Gear);
   525     doStepFallingGear(Gear);
   523     CalcRotationDirAngle(Gear);
   526     CalcRotationDirAngle(Gear);
   524     if (Gear^.State and gstCollision) <> 0 then
   527     if (Gear^.State and gstCollision) <> 0 then
   525         begin
   528         begin
   526         kick:= hwRound((hwAbs(Gear^.dX)+hwAbs(Gear^.dY)) * _20);
   529         kick:= hwRound((hwAbs(gdX)+hwAbs(gdY)) * _20);
   527         Gear^.dY.isNegative:= not Gear^.dY.isNegative;
   530         Gear^.dX:= gdX;
   528         Gear^.dX.isNegative:= not Gear^.dX.isNegative;
   531         Gear^.dY:= gdY;
   529         AmmoShove(Gear, 0, kick);
   532         AmmoShove(Gear, 0, kick);
   530         for i:= 15 + kick div 10 downto 0 do
   533         for i:= 15 + kick div 10 downto 0 do
   531             begin
   534             begin
   532             particle := AddVisualGear(hwRound(Gear^.X) + Random(25), hwRound(Gear^.Y) + Random(25), vgtDust);
   535             particle := AddVisualGear(hwRound(Gear^.X) + Random(25), hwRound(Gear^.Y) + Random(25), vgtDust);
   533             if particle <> nil then
   536             if particle <> nil then
  2414 ////////////////////////////////////////////////////////////////////////////////
  2417 ////////////////////////////////////////////////////////////////////////////////
  2415 procedure doStepMortar(Gear: PGear);
  2418 procedure doStepMortar(Gear: PGear);
  2416 var
  2419 var
  2417     dX, dY, gdX, gdY: hwFloat;
  2420     dX, dY, gdX, gdY: hwFloat;
  2418     i: LongInt;
  2421     i: LongInt;
  2419     dxn, dyn: boolean;
       
  2420 begin
  2422 begin
  2421     AllInactive := false;
  2423     AllInactive := false;
  2422     dxn := Gear^.dX.isNegative;
  2424     gdX := Gear^.dX;
  2423     dyn := Gear^.dY.isNegative;
  2425     gdY := Gear^.dY;
  2424 
  2426 
  2425     doStepFallingGear(Gear);
  2427     doStepFallingGear(Gear);
  2426     if (Gear^.State and gstCollision) <> 0 then
  2428     if (Gear^.State and gstCollision) <> 0 then
  2427         begin
  2429         begin
  2428         gdX := Gear^.dX;
       
  2429         gdY := Gear^.dY;
       
  2430         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
  2430         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
  2431 
  2431         gdX.isNegative := not gdX.isNegative;
  2432         gdX.isNegative := not dxn;
  2432         gdY.isNegative := not gdY.isNegative;
  2433         gdY.isNegative := not dyn;
  2433         gdX:= gdX*_0_2;
       
  2434         gdY:= gdY*_0_2;
       
  2435 
  2434         for i:= 0 to 4 do
  2436         for i:= 0 to 4 do
  2435             begin
  2437             begin
  2436             dX := gdX + (GetRandomf - _0_5) * _0_03;
  2438             dX := gdX + rndSign(GetRandomf) * _0_03;
  2437             dY := gdY + (GetRandomf - _0_5) * _0_03;
  2439             dY := gdY + rndSign(GetRandomf) * _0_03;
  2438             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25);
  2440             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25);
  2439             end;
  2441             end;
  2440 
  2442 
  2441         DeleteGear(Gear);
  2443         DeleteGear(Gear);
  2442         exit
  2444         exit