hedgewars/uCollisions.pas
changeset 14536 e0af4ce7d8bc
parent 14287 6015b74eea55
child 15306 361e79c6c428
equal deleted inserted replaced
14535:ec0afe1c6024 14536:e0af4ce7d8bc
   499     repeat
   499     repeat
   500         if (y and LAND_HEIGHT_MASK) = 0 then
   500         if (y and LAND_HEIGHT_MASK) = 0 then
   501             begin
   501             begin
   502             if Land[y, x] and Gear^.CollisionMask <> 0 then
   502             if Land[y, x] and Gear^.CollisionMask <> 0 then
   503                 begin
   503                 begin
   504                 if ((Land[y, x] and Gear^.CollisionMask) and lfNotObjMask) <> 0 then
   504                 if ((Land[y, x] and Gear^.CollisionMask) and lfLandMask) <> 0 then
   505                     exit(Land[y, x] and Gear^.CollisionMask)
   505                     exit(Land[y, x] and Gear^.CollisionMask)
   506                 else
   506                 else
   507                     pixel:= Land[y, x] and Gear^.CollisionMask;
   507                     pixel:= Land[y, x] and Gear^.CollisionMask;
   508                 end;
   508                 end;
   509             end;
   509             end;
   565     i:= x + Gear^.Radius * 2 - 2;
   565     i:= x + Gear^.Radius * 2 - 2;
   566     repeat
   566     repeat
   567     if (x and LAND_WIDTH_MASK) = 0 then
   567     if (x and LAND_WIDTH_MASK) = 0 then
   568         if Land[y, x] > 0 then
   568         if Land[y, x] > 0 then
   569             begin
   569             begin
   570             if ((Land[y, x] and Gear^.CollisionMask) and lfNotObjMask) <> 0 then
   570             if ((Land[y, x] and Gear^.CollisionMask) and lfLandMask) <> 0 then
   571                 exit(Land[y, x] and Gear^.CollisionMask)
   571                 exit(Land[y, x] and Gear^.CollisionMask)
   572             else // if Land[y, x] <> 0 then
   572             else // if Land[y, x] <> 0 then
   573                 pixel:= Land[y, x] and Gear^.CollisionMask;
   573                 pixel:= Land[y, x] and Gear^.CollisionMask;
   574             end;
   574             end;
   575     inc(x)
   575     inc(x)
   640     begin
   640     begin
   641     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   641     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   642     i:= y + Gear^.Radius * 2 - 2;
   642     i:= y + Gear^.Radius * 2 - 2;
   643     repeat
   643     repeat
   644         if (y and LAND_HEIGHT_MASK) = 0 then
   644         if (y and LAND_HEIGHT_MASK) = 0 then
   645             if ((Land[y, x] and Gear^.CollisionMask) and lfNotObjMask) <> 0 then
   645             if ((Land[y, x] and Gear^.CollisionMask) and lfLandMask) <> 0 then
   646                 exit(Land[y, x] and Gear^.CollisionMask);
   646                 exit(Land[y, x] and Gear^.CollisionMask);
   647     inc(y)
   647     inc(y)
   648     until (y > i);
   648     until (y > i);
   649     end;
   649     end;
   650 TestCollisionX:= 0
   650 TestCollisionX:= 0
   663     begin
   663     begin
   664     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   664     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   665     i:= x + Gear^.Radius * 2 - 2;
   665     i:= x + Gear^.Radius * 2 - 2;
   666     repeat
   666     repeat
   667         if (x and LAND_WIDTH_MASK) = 0 then
   667         if (x and LAND_WIDTH_MASK) = 0 then
   668             if ((Land[y, x] and Gear^.CollisionMask) and lfNotObjMask) <> 0 then
   668             if ((Land[y, x] and Gear^.CollisionMask) and lfLandMask) <> 0 then
   669                 exit(Land[y, x] and Gear^.CollisionMask);
   669                 exit(Land[y, x] and Gear^.CollisionMask);
   670     inc(x)
   670     inc(x)
   671     until (x > i);
   671     until (x > i);
   672     end;
   672     end;
   673 TestCollisionY:= 0
   673 TestCollisionY:= 0
   979     begin
   979     begin
   980     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   980     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   981     i:= x + Gear^.Radius * 2 - 2;
   981     i:= x + Gear^.Radius * 2 - 2;
   982     repeat
   982     repeat
   983     if (x and LAND_WIDTH_MASK) = 0 then
   983     if (x and LAND_WIDTH_MASK) = 0 then
   984         if (Land[y, x] and lfNotObjMask) <> 0 then
   984         if (Land[y, x] and lfLandMask) <> 0 then
   985             if (not isColl) or (abs(x-gx) < abs(collX-gx)) then
   985             if (not isColl) or (abs(x-gx) < abs(collX-gx)) then
   986                 begin
   986                 begin
   987                 isColl:= true;
   987                 isColl:= true;
   988                 collX := x;
   988                 collX := x;
   989                 end;
   989                 end;