hedgewars/uCollisions.pas
branchios-revival
changeset 11160 f1f044e88039
parent 11077 1fb80cd8ba7b
child 11532 bf86c6cb9341
equal deleted inserted replaced
11158:797bc8d70e75 11160:f1f044e88039
     1 (*
     1 (*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
   209     begin
   209     begin
   210     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   210     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   211     i:= y + Gear^.Radius * 2 - 2;
   211     i:= y + Gear^.Radius * 2 - 2;
   212     repeat
   212     repeat
   213         if (y and LAND_HEIGHT_MASK) = 0 then
   213         if (y and LAND_HEIGHT_MASK) = 0 then
   214             if Land[y, x] and Gear^.CollisionMask > 255 then
   214             begin
   215                 exit(Land[y, x] and Gear^.CollisionMask)
   215             if Land[y, x] and Gear^.CollisionMask <> 0 then
   216             else if Land[y, x] and Gear^.CollisionMask <> 0 then
   216                 begin
   217                 pixel:= Land[y, x] and Gear^.CollisionMask;
   217                 if Land[y, x] and Gear^.CollisionMask > 255 then
       
   218                     exit(Land[y, x] and Gear^.CollisionMask)
       
   219                 else
       
   220                     pixel:= Land[y, x] and Gear^.CollisionMask;
       
   221                 end;
       
   222             end;
   218     inc(y)
   223     inc(y)
   219     until (y > i);
   224     until (y > i);
   220     end;
   225     end;
   221 TestCollisionXKick:= pixel;
   226 TestCollisionXKick:= pixel;
   222 
   227 
   272     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   277     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   273     i:= x + Gear^.Radius * 2 - 2;
   278     i:= x + Gear^.Radius * 2 - 2;
   274     repeat
   279     repeat
   275     if (x and LAND_WIDTH_MASK) = 0 then
   280     if (x and LAND_WIDTH_MASK) = 0 then
   276         if Land[y, x] > 0 then
   281         if Land[y, x] > 0 then
       
   282             begin
   277             if Land[y, x] and Gear^.CollisionMask > 255 then
   283             if Land[y, x] and Gear^.CollisionMask > 255 then
   278                 exit(Land[y, x] and Gear^.CollisionMask)
   284                 exit(Land[y, x] and Gear^.CollisionMask)
   279             else if Land[y, x] <> 0 then
   285             else // if Land[y, x] <> 0 then
   280                 pixel:= Land[y, x] and Gear^.CollisionMask;
   286                 pixel:= Land[y, x] and Gear^.CollisionMask;
       
   287             end;
   281     inc(x)
   288     inc(x)
   282     until (x > i);
   289     until (x > i);
   283     end;
   290     end;
   284 TestCollisionYKick:= pixel;
   291 TestCollisionYKick:= pixel;
   285 
   292