hedgewars/uCollisions.pas
changeset 7489 43a998fbacfe
parent 7305 b242e91a92a9
child 7754 e81dc9bef8b8
equal deleted inserted replaced
7486:f3a13da9fa4e 7489:43a998fbacfe
    80 with cinfos[Count] do
    80 with cinfos[Count] do
    81     begin
    81     begin
    82     X:= hwRound(Gear^.X);
    82     X:= hwRound(Gear^.X);
    83     Y:= hwRound(Gear^.Y);
    83     Y:= hwRound(Gear^.Y);
    84     Radius:= Gear^.Radius;
    84     Radius:= Gear^.Radius;
    85     ChangeRoundInLand(X, Y, Radius - 1, true, Gear = CurrentHedgehog^.Gear);
    85     ChangeRoundInLand(X, Y, Radius - 1, true, (Gear = CurrentHedgehog^.Gear) or (Gear^.Kind = gtCase));
    86     cGear:= Gear
    86     cGear:= Gear
    87     end;
    87     end;
    88 Gear^.CollisionIndex:= Count;
    88 Gear^.CollisionIndex:= Count;
    89 inc(Count);
    89 inc(Count);
    90 // mines are the easiest way to overflow collision
    90 // mines are the easiest way to overflow collision
   101 procedure DeleteCI(Gear: PGear);
   101 procedure DeleteCI(Gear: PGear);
   102 begin
   102 begin
   103 if Gear^.CollisionIndex >= 0 then
   103 if Gear^.CollisionIndex >= 0 then
   104     begin
   104     begin
   105     with cinfos[Gear^.CollisionIndex] do
   105     with cinfos[Gear^.CollisionIndex] do
   106         ChangeRoundInLand(X, Y, Radius - 1, false, Gear = CurrentHedgehog^.Gear);
   106         ChangeRoundInLand(X, Y, Radius - 1, false, (Gear = CurrentHedgehog^.Gear) or (Gear^.Kind = gtCase));
   107     cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)];
   107     cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)];
   108     cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex;
   108     cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex;
   109     Gear^.CollisionIndex:= -1;
   109     Gear^.CollisionIndex:= -1;
   110     dec(Count)
   110     dec(Count)
   111     end;
   111     end;
   136 
   136 
   137 function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
   137 function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
   138 var x, y, i: LongInt;
   138 var x, y, i: LongInt;
   139 begin
   139 begin
   140 // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
   140 // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
   141 if (Gear^.CollisionMask = $FF7F) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
   141 if (Gear^.CollisionMask = $FF7F) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
   142     ((hwRound(Gear^.Hedgehog^.Gear^.X) + Gear^.Hedgehog^.Gear^.Radius + 4 < hwRound(Gear^.X) - Gear^.Radius) or
   142     ((hwRound(Gear^.Hedgehog^.Gear^.X) + Gear^.Hedgehog^.Gear^.Radius + 4 < hwRound(Gear^.X) - Gear^.Radius) or
   143      (hwRound(Gear^.Hedgehog^.Gear^.X) - Gear^.Hedgehog^.Gear^.Radius - 4 > hwRound(Gear^.X) + Gear^.Radius)) then
   143      (hwRound(Gear^.Hedgehog^.Gear^.X) - Gear^.Hedgehog^.Gear^.Radius - 4 > hwRound(Gear^.X) + Gear^.Radius)) then
   144     Gear^.CollisionMask:= $FFFF;
   144     Gear^.CollisionMask:= $FFFF;
   145 
   145 
   146 x:= hwRound(Gear^.X);
   146 x:= hwRound(Gear^.X);
   166 
   166 
   167 function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word;
   167 function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word;
   168 var x, y, i: LongInt;
   168 var x, y, i: LongInt;
   169 begin
   169 begin
   170 // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
   170 // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
   171 if (Gear^.CollisionMask = $FF7F) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
   171 if (Gear^.CollisionMask = $FF7F) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
   172     ((hwRound(Gear^.Hedgehog^.Gear^.Y) + Gear^.Hedgehog^.Gear^.Radius + 4 < hwRound(Gear^.Y) - Gear^.Radius) or
   172     ((hwRound(Gear^.Hedgehog^.Gear^.Y) + Gear^.Hedgehog^.Gear^.Radius + 4 < hwRound(Gear^.Y) - Gear^.Radius) or
   173      (hwRound(Gear^.Hedgehog^.Gear^.Y) - Gear^.Hedgehog^.Gear^.Radius - 4 > hwRound(Gear^.Y) + Gear^.Radius)) then
   173      (hwRound(Gear^.Hedgehog^.Gear^.Y) - Gear^.Hedgehog^.Gear^.Radius - 4 > hwRound(Gear^.Y) + Gear^.Radius)) then
   174     Gear^.CollisionMask:= $FFFF;
   174     Gear^.CollisionMask:= $FFFF;
   175 
   175 
   176 y:= hwRound(Gear^.Y);
   176 y:= hwRound(Gear^.Y);