hedgewars/uGearsHandlersRope.pas
branchtransitional_engine
changeset 15929 128ace913837
parent 14674 4aec7d17ef7d
equal deleted inserted replaced
15928:73cdc306888f 15929:128ace913837
    24 
    24 
    25 procedure doStepRope(Gear: PGear);
    25 procedure doStepRope(Gear: PGear);
    26 
    26 
    27 implementation
    27 implementation
    28 uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
    28 uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
    29     uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender;
    29     uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender, uLandUtils;
    30 
    30 
    31 const
    31 const
    32     IsNilHHFatal = false;
    32     IsNilHHFatal = false;
    33 
    33 
    34 procedure doStepRopeAfterAttack(Gear: PGear);
    34 procedure doStepRopeAfterAttack(Gear: PGear);
   239 
   239 
   240     while len > _3 do
   240     while len > _3 do
   241         begin
   241         begin
   242         lx := hwRound(nx);
   242         lx := hwRound(nx);
   243         ly := hwRound(ny);
   243         ly := hwRound(ny);
   244         if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] > lfAllObjMask) then
   244         if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (LandGet(ly, lx) > lfAllObjMask) then
   245             begin
   245             begin
   246             tx := _1 / Distance(ropeDx, ropeDy);
   246             tx := _1 / Distance(ropeDx, ropeDy);
   247             // old rope pos
   247             // old rope pos
   248             nx := ropeDx * tx;
   248             nx := ropeDx * tx;
   249             ny := ropeDy * tx;
   249             ny := ropeDy * tx;
   356         len := _3_2 / hwSqrt(len);
   356         len := _3_2 / hwSqrt(len);
   357         HHGear^.dX := HHGear^.dX * len;
   357         HHGear^.dX := HHGear^.dX * len;
   358         HHGear^.dY := HHGear^.dY * len;
   358         HHGear^.dY := HHGear^.dY * len;
   359         end;
   359         end;
   360 
   360 
   361     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)]) <> 0);
   361     haveCollision:= ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) and ((LandGet(hwRound(Gear^.Y), hwRound(Gear^.X))) <> 0);
   362 
   362 
   363     if not haveCollision then
   363     if not haveCollision then
   364         begin
   364         begin
   365         // backup gear location
   365         // backup gear location
   366         tx:= Gear^.X;
   366         tx:= Gear^.X;
   472         tt := Gear^.Elasticity;
   472         tt := Gear^.Elasticity;
   473         tx := _0;
   473         tx := _0;
   474         ty := _0;
   474         ty := _0;
   475         while tt > _20 do
   475         while tt > _20 do
   476             begin
   476             begin
   477             if ((hwRound(Gear^.Y+ty) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X+tx) and LAND_WIDTH_MASK) = 0) and (Land[hwRound(Gear^.Y+ty), hwRound(Gear^.X+tx)] > lfAllObjMask) then
   477             if ((hwRound(Gear^.Y+ty) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X+tx) and LAND_WIDTH_MASK) = 0) and (LandGet(hwRound(Gear^.Y+ty), hwRound(Gear^.X+tx)) > lfAllObjMask) then
   478                 begin
   478                 begin
   479                 Gear^.X := Gear^.X + tx;
   479                 Gear^.X := Gear^.X + tx;
   480                 Gear^.Y := Gear^.Y + ty;
   480                 Gear^.Y := Gear^.Y + ty;
   481                 Gear^.Elasticity := tt;
   481                 Gear^.Elasticity := tt;
   482                 Gear^.doStep := @doStepRopeWork;
   482                 Gear^.doStep := @doStepRopeWork;