hedgewars/GSHandlers.inc
changeset 4397 ab577db125c4
parent 4396 3cfd2e15464a
child 4400 b190572290a0
equal deleted inserted replaced
4396:3cfd2e15464a 4397:ab577db125c4
   171     end
   171     end
   172     else
   172     else
   173         CheckGearDrowning := false;
   173         CheckGearDrowning := false;
   174 end;
   174 end;
   175 
   175 
   176 procedure CheckCollision(Gear: PGear);
   176 procedure CheckCollision(Gear: PGear); inline;
   177 begin
   177 begin
   178     if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)
   178     if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)
   179        )
   179        )
   180         then Gear^.State := Gear^.State or      gstCollision
   180         then Gear^.State := Gear^.State or      gstCollision
   181     else Gear^.State := Gear^.State and not gstCollision
   181     else Gear^.State := Gear^.State and not gstCollision
  1238 
  1238 
  1239     while len > _3 do
  1239     while len > _3 do
  1240         begin
  1240         begin
  1241         lx := hwRound(nx);
  1241         lx := hwRound(nx);
  1242         ly := hwRound(ny);
  1242         ly := hwRound(ny);
  1243         if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then
  1243         if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and ((Land[ly, lx] and $FF00) <> 0) then
  1244             begin
  1244             begin
  1245             ny := _1 / Distance(ropeDx, ropeDy);
  1245             ny := _1 / Distance(ropeDx, ropeDy);
  1246             // old rope pos
  1246             // old rope pos
  1247             nx := ropeDx * ny;
  1247             nx := ropeDx * ny;
  1248             ny := ropeDy * ny;
  1248             ny := ropeDy * ny;
  1395         tt := Gear^.Elasticity;
  1395         tt := Gear^.Elasticity;
  1396         tx := _0;
  1396         tx := _0;
  1397         ty := _0;
  1397         ty := _0;
  1398         while tt > _20 do
  1398         while tt > _20 do
  1399             begin
  1399             begin
  1400             if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
  1400             if ((hwRound(ty) and LAND_HEIGHT_MASK) = 0) and ((hwRound(tx) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(ty), hwRound(tx)] and $F0) <> 0) then
  1401                or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
       
  1402                 begin
  1401                 begin
  1403                 Gear^.X := Gear^.X + tx;
  1402                 Gear^.X := Gear^.X + tx;
  1404                 Gear^.Y := Gear^.Y + ty;
  1403                 Gear^.Y := Gear^.Y + ty;
  1405                 Gear^.Elasticity := tt;
  1404                 Gear^.Elasticity := tt;
  1406                 Gear^.doStep := @doStepRopeWork;
  1405                 Gear^.doStep := @doStepRopeWork;
  1420             ty := ty + Gear^.dY + Gear^.dY;
  1419             ty := ty + Gear^.dY + Gear^.dY;
  1421             tt := tt - _2;
  1420             tt := tt - _2;
  1422             end;
  1421             end;
  1423         end;
  1422         end;
  1424 
  1423 
  1425     CheckCollision(Gear);
  1424     if ((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) then
       
  1425         Gear^.State:= Gear^.State or gstCollision
       
  1426     else Gear^.State:= Gear^.State and not gstCollision;
  1426 
  1427 
  1427     if (Gear^.State and gstCollision) <> 0 then
  1428     if (Gear^.State and gstCollision) <> 0 then
  1428         if Gear^.Elasticity < _10 then
  1429         if Gear^.Elasticity < _10 then
  1429             Gear^.Elasticity := _10000
  1430             Gear^.Elasticity := _10000
  1430     else
  1431     else