hedgewars/GSHandlers.inc
changeset 3303 397a8f048bb3
parent 3299 aff2315a2843
child 3307 275af46392bd
equal deleted inserted replaced
3302:0973c5af5141 3303:397a8f048bb3
  1068     // check whether rope needs dividing
  1068     // check whether rope needs dividing
  1069     len:= _1 / Distance(ropeDx, ropeDy); // old rope pos
  1069     len:= _1 / Distance(ropeDx, ropeDy); // old rope pos
  1070     nx:= ropeDx * len;
  1070     nx:= ropeDx * len;
  1071     ny:= ropeDy * len;
  1071     ny:= ropeDy * len;
  1072 
  1072 
  1073     len:= Gear^.Elasticity - _0_3x70;
  1073     len:= Gear^.Elasticity - _5;
  1074     while len > _3 do
  1074     while len > _3 do
  1075             begin
  1075             begin
  1076             lx:= hwRound(Gear^.X + mdX * len);
  1076             lx:= hwRound(Gear^.X + mdX * len);
  1077             ly:= hwRound(Gear^.Y + mdY * len);
  1077             ly:= hwRound(Gear^.Y + mdY * len);
  1078             if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then
  1078             if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then
  1106 if not haveDivided then
  1106 if not haveDivided then
  1107     if RopePoints.Count > 0 then // check whether the last dividing point could be removed
  1107     if RopePoints.Count > 0 then // check whether the last dividing point could be removed
  1108         begin
  1108         begin
  1109         tx:= RopePoints.ar[Pred(RopePoints.Count)].X;
  1109         tx:= RopePoints.ar[Pred(RopePoints.Count)].X;
  1110         ty:= RopePoints.ar[Pred(RopePoints.Count)].Y;
  1110         ty:= RopePoints.ar[Pred(RopePoints.Count)].Y;
  1111         if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then
  1111         mdX:= tx - Gear^.X;
       
  1112         mdY:= ty - Gear^.Y;
       
  1113         if RopePoints.ar[Pred(RopePoints.Count)].b xor (mdX * (ty - HHGear^.Y) > (tx - HHGear^.X) * mdY) then
  1112             begin
  1114             begin
  1113             dec(RopePoints.Count);
  1115             dec(RopePoints.Count);
  1114             Gear^.X:= RopePoints.ar[RopePoints.Count].X;
  1116             Gear^.X:= RopePoints.ar[RopePoints.Count].X;
  1115             Gear^.Y:= RopePoints.ar[RopePoints.Count].Y;
  1117             Gear^.Y:= RopePoints.ar[RopePoints.Count].Y;
  1116             Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
  1118             Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
  1117             Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen
  1119             Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen;
       
  1120 
       
  1121             // restore hog position
       
  1122             len:= _1 / Distance(mdX, mdY);
       
  1123             mdX:= mdX * len; 
       
  1124             mdY:= mdY * len;
       
  1125 
       
  1126             HHGear^.X:= Gear^.X - mdX * Gear^.Elasticity;
       
  1127             HHGear^.Y:= Gear^.Y - mdY * Gear^.Elasticity;
  1118             end
  1128             end
  1119         end;
  1129         end;
  1120 
  1130 
  1121 haveCollision:= false;
  1131 haveCollision:= false;
  1122 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
  1132 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then