hedgewars/uCollisions.pas
changeset 15302 9299f43ba0ec
parent 15301 361e79c6c428
child 15303 b761efebe3c4
equal deleted inserted replaced
15301:361e79c6c428 15302:9299f43ba0ec
  1054     p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
  1054     p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
  1055     Gear:= GearsList;
  1055     Gear:= GearsList;
  1056 
  1056 
  1057     while Gear <> nil do
  1057     while Gear <> nil do
  1058         begin
  1058         begin
  1059         if (Gear^.Kind = gtAirMine) or ((Gear^.Kind = gtHedgehog) and (Gear^.CollisionIndex <> 0)) then
  1059         if (Gear^.Kind = gtAirMine) or ((Gear^.Kind = gtHedgehog) and (Gear^.CollisionIndex = 0)) then
  1060             begin
  1060             begin
  1061             gx:= hwRound(Gear^.X);
  1061             gx:= hwRound(Gear^.X);
  1062             gy:= hwRound(Gear^.Y);
  1062             gy:= hwRound(Gear^.Y);
  1063             r:= Gear^.Radius;
  1063             r:= Gear^.Radius + 1;
  1064             if (gx + r >= sprX) and (gx - r < sprX + w) and (gy + r >= sprY) and (gy - r < sprY + h) then
  1064             if (gx + r >= sprX) and (gx - r < sprX + w) and (gy + r >= sprY) and (gy - r < sprY + h) then
  1065                 for y := gy - r to gy + r do
  1065                 for y := gy - r to gy + r do
  1066                     for x := gx - r to gx + r do
  1066                     for x := gx - r to gx + r do
  1067                         begin
  1067                         begin
  1068                         if (x >= sprX) and (x < sprX + w) and (y >= sprY) and (y < sprY + h)
  1068                         if (x >= sprX) and (x < sprX + w) and (y >= sprY) and (y < sprY + h)
  1069                         and (Sqr(x - gx) + Sqr(y - gy) < Sqr(r))
  1069                         and (Sqr(x - gx) + Sqr(y - gy) <= Sqr(r))
  1070                         and (((PLongword(@(p^[Image^.pitch * y + x * 4]))^) and AMask) <> 0) then
  1070                         and (((PLongword(@(p^[Image^.pitch * (y - sprY) + (x - sprX) * 4]))^) and AMask) <> 0) then
  1071                             begin
  1071                             begin
  1072                             CheckGearsUnderSprite := true;
  1072                             CheckGearsUnderSprite := true;
  1073                             if SDL_MustLock(Image) then
  1073                             if SDL_MustLock(Image) then
  1074                                 SDL_UnlockSurface(Image);
  1074                                 SDL_UnlockSurface(Image);
  1075                             exit
  1075                             exit