hedgewars/uCollisions.pas
changeset 1753 2ccba26f1aa4
parent 1528 3fee15104c1d
child 1966 31e449e1d9dd
equal deleted inserted replaced
1752:769986d39202 1753:2ccba26f1aa4
   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;
   127 if (x and $FFFFF800) = 0 then
   127 if (x and LAND_WIDTH_MASK) = 0 then
   128    begin
   128    begin
   129    y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   129    y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   130    i:= y + Gear^.Radius * 2 - 2;
   130    i:= y + Gear^.Radius * 2 - 2;
   131    repeat
   131    repeat
   132      if (y and $FFFFFC00) = 0 then
   132      if (y and LAND_HEIGHT_MASK) = 0 then
   133         if Land[y, x] > TestWord then exit(true);
   133         if Land[y, x] > TestWord then exit(true);
   134      inc(y)
   134      inc(y)
   135    until (y > i);
   135    until (y > i);
   136    end;
   136    end;
   137 TestCollisionXwithGear:= false
   137 TestCollisionXwithGear:= false
   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;
   158 if (y and $FFFFFC00) = 0 then
   158 if (y and LAND_HEIGHT_MASK) = 0 then
   159    begin
   159    begin
   160    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   160    x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   161    i:= x + Gear^.Radius * 2 - 2;
   161    i:= x + Gear^.Radius * 2 - 2;
   162    repeat
   162    repeat
   163      if (x and $FFFFF800) = 0 then
   163      if (x and LAND_WIDTH_MASK) = 0 then
   164         if Land[y, x] > TestWord then exit(true);
   164         if Land[y, x] > TestWord then exit(true);
   165      inc(x)
   165      inc(x)
   166    until (x > i);
   166    until (x > i);
   167    end;
   167    end;
   168 TestCollisionYwithGear:= false
   168 TestCollisionYwithGear:= false
   174 begin
   174 begin
   175 flag:= false;
   175 flag:= false;
   176 x:= hwRound(Gear^.X);
   176 x:= hwRound(Gear^.X);
   177 if Dir < 0 then x:= x - Gear^.Radius
   177 if Dir < 0 then x:= x - Gear^.Radius
   178            else x:= x + Gear^.Radius;
   178            else x:= x + Gear^.Radius;
   179 if (x and $FFFFF800) = 0 then
   179 if (x and LAND_WIDTH_MASK) = 0 then
   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 $FFFFFC00) = 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] = COLOR_LAND 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;
   224 begin
   224 begin
   225 flag:= false;
   225 flag:= false;
   226 y:= hwRound(Gear^.Y);
   226 y:= hwRound(Gear^.Y);
   227 if Dir < 0 then y:= y - Gear^.Radius
   227 if Dir < 0 then y:= y - Gear^.Radius
   228            else y:= y + Gear^.Radius;
   228            else y:= y + Gear^.Radius;
   229 if (y and $FFFFFC00) = 0 then
   229 if (y and LAND_HEIGHT_MASK) = 0 then
   230    begin
   230    begin
   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 $FFFFF800) = 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] = COLOR_LAND 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);
   283 var x, y, i: LongInt;
   283 var x, y, i: LongInt;
   284 begin
   284 begin
   285 y:= hwRound(Gear^.Y);
   285 y:= hwRound(Gear^.Y);
   286 if Dir < 0 then y:= y - Gear^.Radius
   286 if Dir < 0 then y:= y - Gear^.Radius
   287            else y:= y + Gear^.Radius;
   287            else y:= y + Gear^.Radius;
   288 if (y and $FFFFFC00) = 0 then
   288 if (y and LAND_HEIGHT_MASK) = 0 then
   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 $FFFFF800) = 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] = COLOR_LAND 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