hedgewars/GSHandlers.inc
changeset 3585 39570d86de57
parent 3584 7c05f2e0a8b5
child 3588 eb3b6cc490e1
equal deleted inserted replaced
3584:7c05f2e0a8b5 3585:39570d86de57
  1153 
  1153 
  1154     haveDivided := false;
  1154     haveDivided := false;
  1155     // check whether rope needs dividing
  1155     // check whether rope needs dividing
  1156 
  1156 
  1157     len := Gear^.Elasticity - _5;
  1157     len := Gear^.Elasticity - _5;
       
  1158     nx := Gear^.X + mdX * len;
       
  1159     ny := Gear^.Y + mdY * len;
       
  1160     tx := mdX * _0_3; // should be the same as increase step
       
  1161     ty := mdY * _0_3;
       
  1162 
  1158     while len > _3 do
  1163     while len > _3 do
  1159     begin
  1164     begin
  1160         lx := hwRound(Gear^.X + mdX * len);
  1165         lx := hwRound(nx);
  1161         ly := hwRound(Gear^.Y + mdY * len);
  1166         ly := hwRound(ny);
  1162         if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0
  1167         if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0
  1163            ) then
  1168            ) then
  1164         begin
  1169         begin
  1165             // calculate those the first time we have to divide the rope
       
  1166             if not haveDivided then
       
  1167             begin
       
  1168             ny := _1 / Distance(ropeDx, ropeDy);
  1170             ny := _1 / Distance(ropeDx, ropeDy);
  1169             // old rope pos
  1171             // old rope pos
  1170             nx := ropeDx * ny;
  1172             nx := ropeDx * ny;
  1171             ny := ropeDy * ny;
  1173             ny := ropeDy * ny;
  1172             end;
       
  1173 
  1174 
  1174             with RopePoints.ar[RopePoints.Count] do
  1175             with RopePoints.ar[RopePoints.Count] do
  1175             begin
  1176             begin
  1176                 X := Gear^.X;
  1177                 X := Gear^.X;
  1177                 Y := Gear^.Y;
  1178                 Y := Gear^.Y;
  1192             Gear^.Elasticity := Gear^.Elasticity - len;
  1193             Gear^.Elasticity := Gear^.Elasticity - len;
  1193             Gear^.Friction := Gear^.Friction - len;
  1194             Gear^.Friction := Gear^.Friction - len;
  1194             haveDivided := true;
  1195             haveDivided := true;
  1195             break
  1196             break
  1196         end;
  1197         end;
       
  1198         nx := nx - tx;
       
  1199         ny := ny - ty;
  1197         len := len - _0_3 // should be the same as increase step
  1200         len := len - _0_3 // should be the same as increase step
  1198     end;
  1201     end;
  1199 
  1202 
  1200     if not haveDivided then
  1203     if not haveDivided then
  1201         if RopePoints.Count > 0 then // check whether the last dividing point could be removed
  1204         if RopePoints.Count > 0 then // check whether the last dividing point could be removed