hedgewars/uGearsHandlersMess.pas
changeset 11858 38fd32724a61
parent 11766 abcdb7bc2620
child 11860 0abbe6f1e4f2
equal deleted inserted replaced
11857:cb137eb71556 11858:38fd32724a61
  3414         inc(Gear^.Pos);
  3414         inc(Gear^.Pos);
  3415         if Gear^.Pos = 5 then
  3415         if Gear^.Pos = 5 then
  3416             PlaySound(sndYoohoo);
  3416             PlaySound(sndYoohoo);
  3417         end;
  3417         end;
  3418 
  3418 
  3419     if (Gear^.Pos = 14) and (RealTicks and $3 = 0) then
  3419 
       
  3420     // note: use GameTicks, not RealTicks, otherwise amount can vary greatly
       
  3421     if (Gear^.Pos = 14) and (GameTicks and $3 = 0) then
  3420         begin
  3422         begin
  3421         heart:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot);
  3423         heart:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot);
  3422         if heart <> nil then
  3424         if heart <> nil then
  3423             with heart^ do
  3425             with heart^ do
  3424                 begin
  3426                 begin
       
  3427                 { // old calcs
  3425                 dx:= 0.001 * (random(200));
  3428                 dx:= 0.001 * (random(200));
  3426                 dy:= 0.001 * (random(200));
  3429                 dy:= 0.001 * (random(200));
  3427                 if random(2) = 0 then
  3430                 if random(2) = 0 then
  3428                     dx := -dx;
  3431                     dx := -dx;
  3429                 if random(2) = 0 then
  3432                 if random(2) = 0 then
  3430                     dy := -dy;
  3433                     dy := -dy;
       
  3434                 }
       
  3435 
       
  3436                 // randomize speed in both directions
       
  3437                 dx:= 0.001 * (random(201));
       
  3438                 dy:= 0.001 * (random(201));
       
  3439 
       
  3440                 // half of hearts go down
       
  3441                 if random(2) = 0 then
       
  3442                     begin
       
  3443                     // create a pointy shape
       
  3444                     if 0.2 < dx + dy then
       
  3445                         begin
       
  3446                         dy:= 0.2 - dy;
       
  3447                         dx:= 0.2 - dx;
       
  3448                         end;
       
  3449                     // sin bulge it out a little to avoid corners on the side
       
  3450                     dx:= dx + (dx/0.2) * ((0.2 * sin(pi * ((0.2 - dy) / 0.4))) - (0.2 - dy));
       
  3451                     // change sign
       
  3452                     dy:= -dy;
       
  3453                     end
       
  3454                 else // shape hearts on top into 2 arcs
       
  3455                     dy:= dy * (0.3 + 0.7 * sin(pi * dx / 0.2));
       
  3456 
       
  3457                 // half of the hearts go left
       
  3458                 if random(2) = 0 then
       
  3459                     dx := -dx;
  3431                 FrameTicks:= random(750) + 1000;
  3460                 FrameTicks:= random(750) + 1000;
  3432                 State:= ord(sprSeduction)
  3461                 State:= ord(sprSeduction)
  3433                 end;
  3462                 end;
  3434         end;
  3463         end;
  3435 
  3464