hedgewars/uCollisions.pas
changeset 6986 409dd3851309
parent 6700 e04da46ee43c
child 6990 40e5af28d026
equal deleted inserted replaced
6985:caa41003f42c 6986:409dd3851309
    45 function  TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
    45 function  TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
    46 
    46 
    47 function  TestCollisionX(Gear: PGear; Dir: LongInt): boolean;
    47 function  TestCollisionX(Gear: PGear; Dir: LongInt): boolean;
    48 function  TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
    48 function  TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
    49 
    49 
    50 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
    50 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; inline;
    51 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
    51 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
       
    52 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; inline;
       
    53 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
    52 
    54 
    53 function  TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
    55 function  TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
    54 
    56 
    55 // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45° = _0_5)
    57 // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45° = _0_5)
    56 function  CalcSlopeBelowGear(Gear: PGear): hwFloat;
    58 function  CalcSlopeBelowGear(Gear: PGear): hwFloat;
   316                     exit(false)
   318                     exit(false)
   317                     end
   319                     end
   318     end
   320     end
   319 end;
   321 end;
   320 
   322 
   321 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
   323 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; inline;
       
   324 begin
       
   325     TestCollisionXwithXYShift:= TestCollisionXwithXYShift(Gear, ShiftX, ShiftY, Dir, true);
       
   326 end;
       
   327 
       
   328 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
   322 begin
   329 begin
   323 Gear^.X:= Gear^.X + ShiftX;
   330 Gear^.X:= Gear^.X + ShiftX;
   324 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
   331 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
   325 if withGear then 
   332 if withGear then 
   326     TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir)
   333     TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir)
   370     until (x > i);
   377     until (x > i);
   371     end;
   378     end;
   372 TestCollisionY:= false
   379 TestCollisionY:= false
   373 end;
   380 end;
   374 
   381 
   375 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean;
   382 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; inline;
       
   383 begin
       
   384     TestCollisionYwithXYShift:= TestCollisionYwithXYShift(Gear, ShiftX, ShiftY, Dir, true);
       
   385 end;
       
   386 
       
   387 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean;
   376 begin
   388 begin
   377 Gear^.X:= Gear^.X + int2hwFloat(ShiftX);
   389 Gear^.X:= Gear^.X + int2hwFloat(ShiftX);
   378 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
   390 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
   379 
   391 
   380 if withGear then
   392 if withGear then