hedgewars/GSHandlers.inc
changeset 4801 c0d3c2f5e952
parent 4800 83ee0a10903b
child 4802 4c1041eef577
equal deleted inserted replaced
4800:83ee0a10903b 4801:c0d3c2f5e952
  1500         len := _0_8 / hwSqrt(len);
  1500         len := _0_8 / hwSqrt(len);
  1501         HHGear^.dX := HHGear^.dX * len;
  1501         HHGear^.dX := HHGear^.dX * len;
  1502         HHGear^.dY := HHGear^.dY * len;
  1502         HHGear^.dY := HHGear^.dY * len;
  1503         end;
  1503         end;
  1504 
  1504 
  1505     if RopePoints.Count > 0 then
  1505     haveCollision:= ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y), hwRound(Gear^.X)] and $FF00) <> 0);
       
  1506 
       
  1507     if not haveCollision then
  1506         begin
  1508         begin
  1507         // backup gear location
  1509         // backup gear location
  1508         tx:= Gear^.X;
  1510         tx:= Gear^.X;
  1509         ty:= Gear^.Y;
  1511         ty:= Gear^.Y;
  1510 
  1512 
  1511         // set gear location to the remote end of the rope, the attachment point
  1513         if RopePoints.Count > 0 then
  1512         Gear^.X:= RopePoints.ar[0].X;
  1514             begin
  1513         Gear^.Y:= RopePoints.ar[0].Y;
  1515             // set gear location to the remote end of the rope, the attachment point
       
  1516             Gear^.X:= RopePoints.ar[0].X;
       
  1517             Gear^.Y:= RopePoints.ar[0].Y;
       
  1518             end;
  1514 
  1519 
  1515         CheckCollisionWithLand(Gear);
  1520         CheckCollisionWithLand(Gear);
       
  1521         // if we haven't found any collision yet then check the otheer side too
       
  1522         if (Gear^.State and gstCollision) = 0 then
       
  1523             begin
       
  1524             Gear^.dX.isNegative:= not Gear^.dX.isNegative;
       
  1525             Gear^.dY.isNegative:= not Gear^.dY.isNegative;
       
  1526             CheckCollisionWithLand(Gear);
       
  1527             Gear^.dX.isNegative:= not Gear^.dX.isNegative;
       
  1528             Gear^.dY.isNegative:= not Gear^.dY.isNegative;
       
  1529             end;
       
  1530 
       
  1531         haveCollision:= (Gear^.State and gstCollision) <> 0;
  1516 
  1532 
  1517         // restore gear location
  1533         // restore gear location
  1518         Gear^.X:= tx;
  1534         Gear^.X:= tx;
  1519         Gear^.Y:= ty;
  1535         Gear^.Y:= ty;
  1520         end
  1536         end;
  1521     else
  1537 
  1522         CheckCollisionWithLand(Gear);
  1538     // if the attack key is pressed, lose rope contact as well
  1523 
  1539     if (Gear^.Message and gmAttack) <> 0 then
  1524     if ((Gear^.Message and gmAttack) <> 0)
  1540         haveCollision:= false;
  1525     or ((Gear^.State and gstCollision) = 0) then
  1541 
       
  1542     if not haveCollision then
       
  1543         begin
  1526         if (Gear^.State and gsttmpFlag) <> 0 then
  1544         if (Gear^.State and gsttmpFlag) <> 0 then
  1527             with Gear^.Hedgehog^ do
  1545             with Gear^.Hedgehog^ do
  1528                 begin
  1546                 begin
  1529                 PlaySound(sndRopeRelease);
  1547                 PlaySound(sndRopeRelease);
  1530                 if CurAmmoType <> amParachute then
  1548                 if CurAmmoType <> amParachute then
  1531                     WaitCollision
  1549                     WaitCollision
  1532                 else
  1550                 else
  1533                     DeleteMe
  1551                     DeleteMe
  1534                 end
  1552                 end
  1535     else
  1553         end
  1536     else
  1554     else
  1537         if (Gear^.State and gsttmpFlag) = 0 then
  1555         if (Gear^.State and gsttmpFlag) = 0 then
  1538             Gear^.State := Gear^.State or gsttmpFlag;
  1556             Gear^.State := Gear^.State or gsttmpFlag;
  1539 
  1557 
  1540 end;
  1558 end;