hedgewars/uCollisions.pas
changeset 10818 f642a28cab0c
parent 10635 8e8b320eefad
child 11046 47a8c19ecb60
equal deleted inserted replaced
10816:37410518628e 10818:f642a28cab0c
    50 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline;
    50 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline;
    51 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
    51 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
    52 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline;
    52 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline;
    53 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
    53 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word;
    54 
    54 
    55 function  TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
    55 function  TestRectangleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
    56 
    56 
    57 function  CheckCoordInWater(X, Y: LongInt): boolean; inline;
    57 function  CheckCoordInWater(X, Y: LongInt): boolean; inline;
    58 
    58 
    59 // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45 = _0_5)
    59 // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45 = _0_5)
    60 function  CalcSlopeBelowGear(Gear: PGear): hwFloat;
    60 function  CalcSlopeBelowGear(Gear: PGear): hwFloat;
   396 
   396 
   397 Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
   397 Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
   398 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
   398 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
   399 end;
   399 end;
   400 
   400 
   401 function TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
   401 function TestRectangleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean;
   402 var x, y: LongInt;
   402 var x, y: LongInt;
   403     TestWord: LongWord;
   403     TestWord: LongWord;
   404 begin
   404 begin
   405 TestRectancleForObstacle:= true;
   405 TestRectangleForObstacle:= true;
   406 
   406 
   407 if landOnly then
   407 if landOnly then
   408     TestWord:= 255
   408     TestWord:= 255
   409 else
   409 else
   410     TestWord:= 0;
   410     TestWord:= 0;
   429 for y := y1 to y2 do
   429 for y := y1 to y2 do
   430     for x := x1 to x2 do
   430     for x := x1 to x2 do
   431         if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > TestWord) then
   431         if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > TestWord) then
   432             exit;
   432             exit;
   433 
   433 
   434 TestRectancleForObstacle:= false
   434 TestRectangleForObstacle:= false
   435 end;
   435 end;
   436 
   436 
   437 function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean;
   437 function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean;
   438 var ldx, ldy, rdx, rdy: LongInt;
   438 var ldx, ldy, rdx, rdy: LongInt;
   439     i, j, k, mx, my, li, ri, jfr, jto, tmpo : ShortInt;
   439     i, j, k, mx, my, li, ri, jfr, jto, tmpo : ShortInt;