hedgewars/uCollisions.pas
changeset 2716 b9ca1bfca24f
parent 2630 079ef82eac75
child 2948 3f21a9dc93d0
equal deleted inserted replaced
2715:0e4e0db79e2a 2716:b9ca1bfca24f
    28 	TGearArray = record
    28 	TGearArray = record
    29 			ar: array[0..cMaxGearArrayInd] of PGear;
    29 			ar: array[0..cMaxGearArrayInd] of PGear;
    30 			Count: Longword
    30 			Count: Longword
    31 			end;
    31 			end;
    32 
    32 
       
    33 procedure init_uCollisions;
       
    34 procedure free_uCollisions;
       
    35 
    33 procedure AddGearCI(Gear: PGear);
    36 procedure AddGearCI(Gear: PGear);
    34 procedure DeleteCI(Gear: PGear);
    37 procedure DeleteCI(Gear: PGear);
    35 
    38 
    36 function CheckGearsCollision(Gear: PGear): PGearArray;
    39 function  CheckGearsCollision(Gear: PGear): PGearArray;
    37 
    40 
    38 function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
    41 function  TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
    39 function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean;
    42 function  TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean;
    40 
    43 
    41 function TestCollisionXKick(Gear: PGear; Dir: LongInt): boolean;
    44 function  TestCollisionXKick(Gear: PGear; Dir: LongInt): boolean;
    42 function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
    45 function  TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
    43 
    46 
    44 function TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
    47 function  TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
    45 
    48 
    46 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
    49 function  TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
    47 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean;
    50 function  TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean;
    48 
    51 
    49 implementation
    52 implementation
    50 uses uMisc, uConsts, uLand, uLandGraphics, uConsole;
    53 uses uMisc, uConsts, uLand, uLandGraphics, uConsole;
    51 
    54 
    52 type TCollisionEntry = record
    55 type TCollisionEntry = record
    53 			X, Y, Radius: LongInt;
    56 			X, Y, Radius: LongInt;
    54 			cGear: PGear;
    57 			cGear: PGear;
    55 			end;
    58 			end;
    56 
    59 
    57 const MAXRECTSINDEX = 511;
    60 const MAXRECTSINDEX = 511;
    58 var Count: Longword = 0;
    61 var Count: Longword;
    59 	cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry;
    62     cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry;
    60 	ga: TGearArray;
    63     ga: TGearArray;
    61 
    64 
    62 procedure AddGearCI(Gear: PGear);
    65 procedure AddGearCI(Gear: PGear);
    63 begin
    66 begin
    64 if Gear^.CollisionIndex >= 0 then exit;
    67 if Gear^.CollisionIndex >= 0 then exit;
    65 TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
    68 TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
   307 TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir);
   310 TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir);
   308 Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
   311 Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
   309 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
   312 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
   310 end;
   313 end;
   311 
   314 
       
   315 procedure init_uCollisions;
       
   316 begin
       
   317 	Count:= 0;
       
   318 end;
       
   319 
       
   320 procedure free_uCollisions;
       
   321 begin
       
   322 
       
   323 end;
       
   324 
   312 end.
   325 end.