hedgewars/uCollisions.pas
changeset 9731 953197ac43d8
parent 9708 7d146637cb81
child 9737 f0769402350c
equal deleted inserted replaced
9730:20dca3377887 9731:953197ac43d8
   155     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   155     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   156     i:= y + Gear^.Radius * 2 - 2;
   156     i:= y + Gear^.Radius * 2 - 2;
   157     repeat
   157     repeat
   158         if (y and LAND_HEIGHT_MASK) = 0 then
   158         if (y and LAND_HEIGHT_MASK) = 0 then
   159             if Land[y, x] and Gear^.CollisionMask <> 0 then
   159             if Land[y, x] and Gear^.CollisionMask <> 0 then
   160                 exit(Land[y, x]);
   160                 exit(Land[y, x] and Gear^.CollisionMask);
   161         inc(y)
   161         inc(y)
   162     until (y > i);
   162     until (y > i);
   163     end;
   163     end;
   164 TestCollisionXwithGear:= 0
   164 TestCollisionXwithGear:= 0
   165 end;
   165 end;
   185     i:= x + Gear^.Radius * 2 - 2;
   185     i:= x + Gear^.Radius * 2 - 2;
   186     repeat
   186     repeat
   187         if (x and LAND_WIDTH_MASK) = 0 then
   187         if (x and LAND_WIDTH_MASK) = 0 then
   188             if Land[y, x] and Gear^.CollisionMask <> 0 then
   188             if Land[y, x] and Gear^.CollisionMask <> 0 then
   189                 begin
   189                 begin
   190                 TestCollisionYwithGear:= Land[y, x];
   190                 exit(Land[y, x] and Gear^.CollisionMask)
   191                 exit(Land[y, x]);
       
   192                 end;
   191                 end;
   193         inc(x)
   192         inc(x)
   194     until (x > i);
   193     until (x > i);
   195     end;
   194     end;
   196 TestCollisionYwithGear:= 0
   195 TestCollisionYwithGear:= 0
   211     begin
   210     begin
   212     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   211     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   213     i:= y + Gear^.Radius * 2 - 2;
   212     i:= y + Gear^.Radius * 2 - 2;
   214     repeat
   213     repeat
   215         if (y and LAND_HEIGHT_MASK) = 0 then
   214         if (y and LAND_HEIGHT_MASK) = 0 then
   216             if Land[y, x] > 255 then
   215             if Land[y, x] and Gear^.CollisionMask > 255 then
   217                 exit(Land[y, x])
   216                 exit(Land[y, x] and Gear^.CollisionMask)
   218             else if Land[y, x] <> 0 then
   217             else if Land[y, x] and Gear^.CollisionMask <> 0 then
   219                 pixel:= Land[y, x];
   218                 pixel:= Land[y, x] and Gear^.CollisionMask;
   220     inc(y)
   219     inc(y)
   221     until (y > i);
   220     until (y > i);
   222     end;
   221     end;
   223 TestCollisionXKick:= pixel;
   222 TestCollisionXKick:= pixel;
   224 
   223 
   274     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   273     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   275     i:= x + Gear^.Radius * 2 - 2;
   274     i:= x + Gear^.Radius * 2 - 2;
   276     repeat
   275     repeat
   277     if (x and LAND_WIDTH_MASK) = 0 then
   276     if (x and LAND_WIDTH_MASK) = 0 then
   278         if Land[y, x] > 0 then
   277         if Land[y, x] > 0 then
   279             if Land[y, x] > 255 then
   278             if Land[y, x] and Gear^.CollisionMask > 255 then
   280                 exit(Land[y, x])
   279                 exit(Land[y, x] and Gear^.CollisionMask)
   281             else if Land[y, x] <> 0 then
   280             else if Land[y, x] <> 0 then
   282                 pixel:= Land[y, x];
   281                 pixel:= Land[y, x] and Gear^.CollisionMask;
   283     inc(x)
   282     inc(x)
   284     until (x > i);
   283     until (x > i);
   285     end;
   284     end;
   286 TestCollisionYKick:= pixel;
   285 TestCollisionYKick:= pixel;
   287 
   286 
   348     begin
   347     begin
   349     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   348     y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
   350     i:= y + Gear^.Radius * 2 - 2;
   349     i:= y + Gear^.Radius * 2 - 2;
   351     repeat
   350     repeat
   352         if (y and LAND_HEIGHT_MASK) = 0 then
   351         if (y and LAND_HEIGHT_MASK) = 0 then
   353             if Land[y, x] > 255 then
   352             if Land[y, x] and Gear^.CollisionMask > 255 then
   354                 exit(Land[y, x]);
   353                 exit(Land[y, x] and Gear^.CollisionMask);
   355     inc(y)
   354     inc(y)
   356     until (y > i);
   355     until (y > i);
   357     end;
   356     end;
   358 TestCollisionX:= 0
   357 TestCollisionX:= 0
   359 end;
   358 end;
   371     begin
   370     begin
   372     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   371     x:= hwRound(Gear^.X) - Gear^.Radius + 1;
   373     i:= x + Gear^.Radius * 2 - 2;
   372     i:= x + Gear^.Radius * 2 - 2;
   374     repeat
   373     repeat
   375         if (x and LAND_WIDTH_MASK) = 0 then
   374         if (x and LAND_WIDTH_MASK) = 0 then
   376             if Land[y, x] > 255 then
   375             if Land[y, x] and Gear^.CollisionMask > 255 then
   377                 exit(Land[y, x]);
   376                 exit(Land[y, x] and Gear^.CollisionMask);
   378     inc(x)
   377     inc(x)
   379     until (x > i);
   378     until (x > i);
   380     end;
   379     end;
   381 TestCollisionY:= 0
   380 TestCollisionY:= 0
   382 end;
   381 end;