hedgewars/uCollisions.pas
changeset 68 cbb93eb90304
parent 64 9df467527ae5
child 70 82d93eeecebe
--- a/hedgewars/uCollisions.pas	Tue Jun 20 21:20:06 2006 +0000
+++ b/hedgewars/uCollisions.pas	Tue Jun 20 21:21:31 2006 +0000
@@ -49,9 +49,9 @@
 procedure AddGearCI(Gear: PGear);
 procedure DeleteCI(Gear: PGear);
 function CheckGearsCollision(Gear: PGear): PGearArray;
-function  HHTestCollisionYwithGear(Gear: PGear; Dir: integer): boolean;
 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean;
 function TestCollisionYwithGear(Gear: PGear; Dir: integer): boolean;
+function TestCollisionY(Gear: PGear; Dir: integer): boolean;
 function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean;
 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean;
 
@@ -116,43 +116,13 @@
              end;
 end;
 
-function HHTestCollisionYwithGear(Gear: PGear; Dir: integer): boolean;
-var x, y, i: integer;
-begin
-Result:= false;
-y:= round(Gear.Y);
-if Dir < 0 then y:= y - Gear.Radius
-           else y:= y + Gear.Radius;
-           
-if ((y - Dir) and $FFFFFC00) = 0 then
-   begin
-   x:= round(Gear.X);
-   if (((x - Gear.Radius) and $FFFFF800) = 0)and(Land[y - Dir, x - Gear.Radius] <> 0)
-    or(((x + Gear.Radius) and $FFFFF800) = 0)and(Land[y - Dir, x + Gear.Radius] <> 0) then
-      begin
-      Result:= true;
-      exit
-      end
-    end;
-
-if (y and $FFFFFC00) = 0 then
-   begin
-   x:= round(Gear.X) - Gear.Radius + 1;
-   i:= x + Gear.Radius * 2 - 2;
-   repeat
-     if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0;
-     inc(x)
-   until (x > i) or Result
-   end
-end;
-
 function TestCollisionXwithGear(Gear: PGear; Dir: integer): boolean;
 var x, y, i: integer;
 begin
 Result:= false;
 x:= round(Gear.X);
-if Dir < 0 then x:= x - Gear.Radius - 1
-           else x:= x + Gear.Radius + 1;
+if Dir < 0 then x:= x - Gear.Radius
+           else x:= x + Gear.Radius;
 if (x and $FFFFF800) = 0 then
    begin
    y:= round(Gear.Y) - Gear.Radius + 1;
@@ -183,7 +153,7 @@
 if (y and $FFFFFC00) = 0 then
    begin
    x:= round(Gear.X) - Gear.Radius + 1;
-   i:= x + Gear.Radius * 2 - 2;            
+   i:= x + Gear.Radius * 2 - 2;
    repeat
      if (x and $FFFFF800) = 0 then Result:= Land[y, x]<>0;
      inc(x)
@@ -191,6 +161,24 @@
    end
 end;
 
+function TestCollisionY(Gear: PGear; Dir: integer): boolean;
+var x, y, i: integer;
+begin
+Result:= false;
+y:= round(Gear.Y);
+if Dir < 0 then y:= y - Gear.Radius
+           else y:= y + Gear.Radius;
+if (y and $FFFFFC00) = 0 then
+   begin
+   x:= round(Gear.X) - Gear.Radius + 1;
+   i:= x + Gear.Radius * 2 - 2;
+   repeat
+     if (x and $FFFFF800) = 0 then Result:= Land[y, x] = COLOR_LAND;
+     inc(x)
+   until (x > i) or Result;
+   end
+end;
+
 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: integer; Dir: integer): boolean;
 begin
 Gear.X:= Gear.X + ShiftX;