hedgewars/uCollisions.pas
changeset 517 ba560c17c24c
parent 514 fb8ba88a83c3
child 521 bc8fd78d7598
equal deleted inserted replaced
516:f682e134ac2e 517:ba560c17c24c
   189      inc(y)
   189      inc(y)
   190    until (y > i);
   190    until (y > i);
   191    end;
   191    end;
   192 TestCollisionXKick:= false;
   192 TestCollisionXKick:= false;
   193 
   193 
   194 if flag then
   194 if flag and (Gear^.dX > cHHKick) then
   195    begin
   195    begin
   196    if Count = 0 then exit;
   196    if Count = 0 then exit;
   197    mx:= hwRound(Gear^.X);
   197    mx:= hwRound(Gear^.X);
   198    my:= hwRound(Gear^.Y);
   198    my:= hwRound(Gear^.Y);
   199 
   199 
   200    for i:= 0 to Pred(Count) do
   200    for i:= 0 to Pred(Count) do
   201     with cinfos[i] do
   201     with cinfos[i] do
   202       if (Gear <> cGear) and
   202       if (Gear <> cGear) and
   203          (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) and
   203          (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) and
   204          ((mx > x) xor (Dir > 0)) then  // FIXME: Check Gear.Kind
   204          ((mx > x) xor (Dir > 0)) then
       
   205          if (cinfos[i].cGear^.Kind in [gtHedgehog, gtMine]) then
   205              begin
   206              begin
   206              Gear^.dX:= Gear^.dX {* _0_6};
   207              Gear^.dX:= Gear^.dX {* _0_6};
   207              Gear^.dY:= Gear^.dY {* _0_6};
   208              Gear^.dY:= Gear^.dY {* _0_6};
   208              with cinfos[i].cGear^ do
   209              with cinfos[i].cGear^ do
   209                   begin
   210                   begin
   212                   State:= State and gstMoving;
   213                   State:= State and gstMoving;
   213                   Active:= true
   214                   Active:= true
   214                   end;
   215                   end;
   215              DeleteCI(cinfos[i].cGear);
   216              DeleteCI(cinfos[i].cGear);
   216              exit
   217              exit
   217              end
   218              end else exit(true)
   218    end
   219    end
   219 end;
   220 end;
   220 
   221 
   221 function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
   222 function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
   222 var x, y, mx, my, i: LongInt;
   223 var x, y, mx, my, i: LongInt;
   238      inc(x)
   239      inc(x)
   239    until (x > i);
   240    until (x > i);
   240    end;
   241    end;
   241 TestCollisionYKick:= false;
   242 TestCollisionYKick:= false;
   242 
   243 
   243 if flag then
   244 if flag and (Gear^.dX > cHHKick) then
   244    begin
   245    begin
   245    if Count = 0 then exit;
   246    if Count = 0 then exit;
   246    mx:= hwRound(Gear^.X);
   247    mx:= hwRound(Gear^.X);
   247    my:= hwRound(Gear^.Y);
   248    my:= hwRound(Gear^.Y);
   248 
   249 
   249    for i:= 0 to Pred(Count) do
   250    for i:= 0 to Pred(Count) do
   250     with cinfos[i] do
   251     with cinfos[i] do
   251       if (Gear <> cGear) and
   252       if (Gear <> cGear) and
   252          (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) and
   253          (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) and
   253          ((my > y) xor (Dir > 0)) then
   254          ((my > y) xor (Dir > 0)) then
       
   255          if (cinfos[i].cGear^.Kind in [gtHedgehog, gtMine]) then
   254              begin
   256              begin
   255              Gear^.dX:= Gear^.dX * _0_6;
   257              Gear^.dX:= Gear^.dX {* _0_6};
   256              Gear^.dY:= Gear^.dY * _0_6;
   258              Gear^.dY:= Gear^.dY {* _0_6};
   257              with cinfos[i].cGear^ do
   259              with cinfos[i].cGear^ do
   258                   begin
   260                   begin
   259                   dX:= Gear^.dX {* _1_5};
   261                   dX:= Gear^.dX {* _1_5};
   260                   dY:= Gear^.dY {* _1_5};
   262                   dY:= Gear^.dY {* _1_5};
   261                   State:= State and gstMoving;
   263                   State:= State and gstMoving;
   262                   Active:= true
   264                   Active:= true
   263                   end;
   265                   end;
   264              DeleteCI(cinfos[i].cGear);
   266              DeleteCI(cinfos[i].cGear);
   265              exit
   267              exit
   266              end
   268              end else exit(true)
   267    end
   269    end
   268 end;
   270 end;
   269 
   271 
   270 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
   272 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
   271 begin
   273 begin