hedgewars/uCollisions.pas
changeset 538 74219eadab5e
parent 536 33538aadb4e7
child 542 ec26095f1bed
equal deleted inserted replaced
537:4d2e60623e44 538:74219eadab5e
   187            if Land[y, x] = COLOR_LAND then exit(true)
   187            if Land[y, x] = COLOR_LAND then exit(true)
   188            else if Land[y, x] <> 0 then flag:= true;
   188            else if Land[y, x] <> 0 then flag:= true;
   189      inc(y)
   189      inc(y)
   190    until (y > i);
   190    until (y > i);
   191    end;
   191    end;
   192 TestCollisionXKick:= false;
   192 TestCollisionXKick:= flag;
   193 
   193 
   194 if flag then
   194 if flag then
   195    begin
   195    begin
   196    if hwAbs(Gear^.dX) < cHHKick then exit(true);
   196    if hwAbs(Gear^.dX) < cHHKick then exit;
   197    if Count = 0 then exit;
       
   198    mx:= hwRound(Gear^.X);
   197    mx:= hwRound(Gear^.X);
   199    my:= hwRound(Gear^.Y);
   198    my:= hwRound(Gear^.Y);
   200 
   199 
   201    for i:= 0 to Pred(Count) do
   200    for i:= 0 to Pred(Count) do
   202     with cinfos[i] do
   201     with cinfos[i] do
   211                   dY:= Gear^.dY;
   210                   dY:= Gear^.dY;
   212                   State:= State or gstMoving;
   211                   State:= State or gstMoving;
   213                   Active:= true
   212                   Active:= true
   214                   end;
   213                   end;
   215              DeleteCI(cGear);
   214              DeleteCI(cGear);
   216              exit
   215              exit(false)
   217              end else exit(true)
   216              end
   218    end
   217    end
   219 end;
   218 end;
   220 
   219 
   221 function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
   220 function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
   222 var x, y, mx, my, i: LongInt;
   221 var x, y, mx, my, i: LongInt;
   236            if Land[y, x] = COLOR_LAND then exit(true)
   235            if Land[y, x] = COLOR_LAND then exit(true)
   237            else if Land[y, x] <> 0 then flag:= true;
   236            else if Land[y, x] <> 0 then flag:= true;
   238      inc(x)
   237      inc(x)
   239    until (x > i);
   238    until (x > i);
   240    end;
   239    end;
   241 TestCollisionYKick:= false;
   240 TestCollisionYKick:= flag;
   242 
   241 
   243 if flag then
   242 if flag then
   244    begin
   243    begin
   245    if hwAbs(Gear^.dX) < cHHKick then exit(true);
   244    if hwAbs(Gear^.dX) < cHHKick then exit(true);
   246    if Count = 0 then exit;
       
   247    mx:= hwRound(Gear^.X);
   245    mx:= hwRound(Gear^.X);
   248    my:= hwRound(Gear^.Y);
   246    my:= hwRound(Gear^.Y);
   249 
   247 
   250    for i:= 0 to Pred(Count) do
   248    for i:= 0 to Pred(Count) do
   251     with cinfos[i] do
   249     with cinfos[i] do
   255          if (cGear^.Kind in [gtHedgehog, gtMine]) then
   253          if (cGear^.Kind in [gtHedgehog, gtMine]) then
   256              begin
   254              begin
   257              with cGear^ do
   255              with cGear^ do
   258                   begin
   256                   begin
   259                   dX:= Gear^.dX;
   257                   dX:= Gear^.dX;
   260                   dY:= Gear^.dY;
   258                   dY:= Gear^.dY * _0_5;
   261                   State:= State or gstMoving;
   259                   State:= State or gstMoving;
   262                   Active:= true
   260                   Active:= true
   263                   end;
   261                   end;
   264              DeleteCI(cGear);
   262              DeleteCI(cGear);
   265              exit
   263              exit(false)
   266              end else exit(true)
   264              end
   267    end
   265    end
   268 end;
   266 end;
   269 
   267 
   270 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
   268 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
   271 begin
   269 begin