hedgewars/uCollisions.pas
changeset 1966 31e449e1d9dd
parent 1753 2ccba26f1aa4
child 2599 c7153d2348f3
equal deleted inserted replaced
1965:340bfd438ca5 1966:31e449e1d9dd
   116            (hwRound(IntersectGear^.X) - IntersectGear^.Radius > hwRound(X) + Radius) then
   116            (hwRound(IntersectGear^.X) - IntersectGear^.Radius > hwRound(X) + Radius) then
   117            begin
   117            begin
   118            IntersectGear:= nil;
   118            IntersectGear:= nil;
   119            TestWord:= 0
   119            TestWord:= 0
   120            end else
   120            end else
   121            TestWord:= COLOR_LAND - 1
   121            TestWord:= 255
   122    else TestWord:= 0;
   122    else TestWord:= 0;
   123 
   123 
   124 x:= hwRound(Gear^.X);
   124 x:= hwRound(Gear^.X);
   125 if Dir < 0 then x:= x - Gear^.Radius
   125 if Dir < 0 then x:= x - Gear^.Radius
   126            else x:= x + Gear^.Radius;
   126            else x:= x + Gear^.Radius;
   147            (hwRound(IntersectGear^.Y) - IntersectGear^.Radius > hwRound(Y) + Radius) then
   147            (hwRound(IntersectGear^.Y) - IntersectGear^.Radius > hwRound(Y) + Radius) then
   148            begin
   148            begin
   149            IntersectGear:= nil;
   149            IntersectGear:= nil;
   150            TestWord:= 0
   150            TestWord:= 0
   151            end else
   151            end else
   152            TestWord:= COLOR_LAND - 1
   152            TestWord:= 255
   153    else TestWord:= 0;
   153    else TestWord:= 0;
   154 
   154 
   155 y:= hwRound(Gear^.Y);
   155 y:= hwRound(Gear^.Y);
   156 if Dir < 0 then y:= y - Gear^.Radius
   156 if Dir < 0 then y:= y - Gear^.Radius
   157            else y:= y + Gear^.Radius;
   157            else y:= y + Gear^.Radius;
   180    begin
   180    begin
   181    y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   181    y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   182    i:= y + Gear^.Radius * 2 - 2;
   182    i:= y + Gear^.Radius * 2 - 2;
   183    repeat
   183    repeat
   184      if (y and LAND_HEIGHT_MASK) = 0 then
   184      if (y and LAND_HEIGHT_MASK) = 0 then
   185            if Land[y, x] = COLOR_LAND then exit(true)
   185            if Land[y, x] > 255 then exit(true)
   186            else if Land[y, x] <> 0 then flag:= true;
   186            else if Land[y, x] <> 0 then flag:= true;
   187      inc(y)
   187      inc(y)
   188    until (y > i);
   188    until (y > i);
   189    end;
   189    end;
   190 TestCollisionXKick:= flag;
   190 TestCollisionXKick:= flag;
   231    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   231    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   232    i:= x + Gear^.Radius * 2 - 2;
   232    i:= x + Gear^.Radius * 2 - 2;
   233    repeat
   233    repeat
   234      if (x and LAND_WIDTH_MASK) = 0 then
   234      if (x and LAND_WIDTH_MASK) = 0 then
   235         if Land[y, x] > 0 then
   235         if Land[y, x] > 0 then
   236            if Land[y, x] = COLOR_LAND then exit(true)
   236            if Land[y, x] > 255 then exit(true)
   237            else if Land[y, x] <> 0 then flag:= true;
   237            else if Land[y, x] <> 0 then flag:= true;
   238      inc(x)
   238      inc(x)
   239    until (x > i);
   239    until (x > i);
   240    end;
   240    end;
   241 TestCollisionYKick:= flag;
   241 TestCollisionYKick:= flag;
   289    begin
   289    begin
   290    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   290    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   291    i:= x + Gear^.Radius * 2 - 2;
   291    i:= x + Gear^.Radius * 2 - 2;
   292    repeat
   292    repeat
   293      if (x and LAND_WIDTH_MASK) = 0 then
   293      if (x and LAND_WIDTH_MASK) = 0 then
   294         if Land[y, x] = COLOR_LAND then exit(true);
   294         if Land[y, x] > 255 then exit(true);
   295      inc(x)
   295      inc(x)
   296    until (x > i);
   296    until (x > i);
   297    end;
   297    end;
   298 TestCollisionY:= false
   298 TestCollisionY:= false
   299 end;
   299 end;