hedgewars/GSHandlers.inc
changeset 6490 531bf083e8db
parent 6474 42e9773eedfd
child 6491 736479f3d348
equal deleted inserted replaced
6489:e1f0058cfedd 6490:531bf083e8db
  2888     end
  2888     end
  2889     else dec(Gear^.Pos)
  2889     else dec(Gear^.Pos)
  2890 end;
  2890 end;
  2891 
  2891 
  2892 
  2892 
       
  2893 procedure PrevAngle(Gear: PGear; dA: LongInt);
       
  2894 begin
       
  2895     Gear^.Angle := (LongInt(Gear^.Angle) + 4 - dA) mod 4
       
  2896 end;
       
  2897 
       
  2898 procedure NextAngle(Gear: PGear; dA: LongInt);
       
  2899 begin
       
  2900     Gear^.Angle := (LongInt(Gear^.Angle) + 4 + dA) mod 4
       
  2901 end;
       
  2902 
  2893 procedure doStepCakeWork(Gear: PGear);
  2903 procedure doStepCakeWork(Gear: PGear);
  2894 
  2904 
  2895 const dirs: array[0..3] of TPoint =   ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0));
  2905 const dirs: array[0..3] of TPoint =   ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0));
  2896 var 
  2906 var 
  2897     xx, yy, xxn, yyn: LongInt;
  2907     xx, yy, xxn, yyn: LongInt;
  2898     da: LongInt;
  2908     dA: LongInt;
  2899     tdx, tdy: hwFloat;
  2909     tdx, tdy: hwFloat;
  2900 
       
  2901 procedure PrevAngle;
       
  2902 begin
       
  2903     Gear^.Angle := (LongInt(Gear^.Angle) + 4 - dA) mod 4
       
  2904 end;
       
  2905 
       
  2906 procedure NextAngle;
       
  2907 begin
       
  2908     Gear^.Angle := (LongInt(Gear^.Angle) + 4 + dA) mod 4
       
  2909 end;
       
  2910 
       
  2911 begin
  2910 begin
  2912     AllInactive := false;
  2911     AllInactive := false;
  2913 
  2912 
  2914     inc(Gear^.Tag);
  2913     inc(Gear^.Tag);
  2915     if Gear^.Tag < 7 then exit;
  2914     if Gear^.Tag < 7 then exit;
  2920     xxn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x;
  2919     xxn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x;
  2921     yyn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y;
  2920     yyn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y;
  2922 
  2921 
  2923     if (xx = 0) then
  2922     if (xx = 0) then
  2924         if TestCollisionYwithGear(Gear, yy) <> 0 then
  2923         if TestCollisionYwithGear(Gear, yy) <> 0 then
  2925             PrevAngle
  2924             PrevAngle(Gear, dA)
  2926     else
  2925     else
  2927     begin
  2926     begin
  2928         Gear^.Tag := 0;
  2927         Gear^.Tag := 0;
  2929         Gear^.Y := Gear^.Y + int2hwFloat(yy);
  2928         Gear^.Y := Gear^.Y + int2hwFloat(yy);
  2930         if not TestCollisionXwithGear(Gear, xxn) then
  2929         if not TestCollisionXwithGear(Gear, xxn) then
  2931         begin
  2930         begin
  2932             Gear^.X := Gear^.X + int2hwFloat(xxn);
  2931             Gear^.X := Gear^.X + int2hwFloat(xxn);
  2933             NextAngle
  2932             NextAngle(Gear, dA)
  2934         end;
  2933         end;
  2935     end;
  2934     end;
  2936 
  2935 
  2937     if (yy = 0) then
  2936     if (yy = 0) then
  2938         if TestCollisionXwithGear(Gear, xx) then
  2937         if TestCollisionXwithGear(Gear, xx) then
  2939             PrevAngle
  2938             PrevAngle(Gear, dA)
  2940     else
  2939     else
  2941     begin
  2940     begin
  2942         Gear^.Tag := 0;
  2941         Gear^.Tag := 0;
  2943         Gear^.X := Gear^.X + int2hwFloat(xx);
  2942         Gear^.X := Gear^.X + int2hwFloat(xx);
  2944         if not TestCollisionY(Gear, yyn) then
  2943         if not TestCollisionY(Gear, yyn) then
  2945         begin
  2944         begin
  2946             Gear^.Y := Gear^.Y + int2hwFloat(yyn);
  2945             Gear^.Y := Gear^.Y + int2hwFloat(yyn);
  2947             NextAngle
  2946             NextAngle(Gear, dA)
  2948         end;
  2947         end;
  2949     end;
  2948     end;
  2950 
  2949 
  2951     if Gear^.Tag = 0 then
  2950     if Gear^.Tag = 0 then
  2952     begin
  2951     begin
  4132 
  4131 
  4133         if Gear^.Health > 1 then dec(Gear^.Health);
  4132         if Gear^.Health > 1 then dec(Gear^.Health);
  4134     end;
  4133     end;
  4135 end;
  4134 end;
  4136 
  4135 
  4137 procedure doStepMovingPortal_real(Gear: PGear);
  4136 
  4138 var 
       
  4139     x, y, tx, ty: LongInt;
       
  4140     s: hwFloat;
       
  4141 
  4137 
  4142 procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean);
  4138 procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean);
  4143 var
  4139 var
  4144     CurWeapon: PAmmo;
  4140     CurWeapon: PAmmo;
  4145 begin
  4141 begin
  4163                 end
  4159                 end
  4164             end;
  4160             end;
  4165     if destroyGear then oldPortal^.Timer:= 0;
  4161     if destroyGear then oldPortal^.Timer:= 0;
  4166 end;
  4162 end;
  4167 
  4163 
       
  4164 procedure doStepMovingPortal_real(Gear: PGear);
       
  4165 var 
       
  4166     x, y, tx, ty: LongInt;
       
  4167     s: hwFloat;
  4168 begin
  4168 begin
  4169     x := hwRound(Gear^.X);
  4169     x := hwRound(Gear^.X);
  4170     y := hwRound(Gear^.Y);
  4170     y := hwRound(Gear^.Y);
  4171     tx := 0;
  4171     tx := 0;
  4172     ty := 0;
  4172     ty := 0;