hedgewars/GSHandlers.inc
changeset 2524 0b075d38fee5
parent 2515 51d3f4b6293a
child 2538 661079b00177
equal deleted inserted replaced
2523:7fc37a16f405 2524:0b075d38fee5
   989 
   989 
   990 begin
   990 begin
   991 Gear^.X:= Gear^.X - Gear^.dX;
   991 Gear^.X:= Gear^.X - Gear^.dX;
   992 Gear^.Y:= Gear^.Y - Gear^.dY;
   992 Gear^.Y:= Gear^.Y - Gear^.dY;
   993 Gear^.Elasticity:= Gear^.Elasticity + _1;
   993 Gear^.Elasticity:= Gear^.Elasticity + _1;
       
   994 
   994 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   995 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   995 DeleteCI(HHGear);
   996 DeleteCI(HHGear);
       
   997 
   996 if (HHGear^.State and gstMoving) <> 0 then
   998 if (HHGear^.State and gstMoving) <> 0 then
   997 	begin
   999 	begin
   998 	if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
  1000 	if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
   999 	if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0;
  1001 	if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0;
  1000 
  1002 
  1009 		end else
  1011 		end else
  1010 		begin
  1012 		begin
  1011 		HHGear^.Y:= HHGear^.Y + HHGear^.dY;
  1013 		HHGear^.Y:= HHGear^.Y + HHGear^.dY;
  1012 		Gear^.Y:= Gear^.Y + HHGear^.dY;
  1014 		Gear^.Y:= Gear^.Y + HHGear^.dY;
  1013 		HHGear^.dY:= HHGear^.dY + cGravity;
  1015 		HHGear^.dY:= HHGear^.dY + cGravity;
  1014 		tt:= Gear^.Elasticity;
  1016 		end;
  1015 		tx:= _0;
  1017 		
  1016 		ty:= _0;
  1018 	tt:= Gear^.Elasticity;
  1017 		while tt > _20 do
  1019 	tx:= _0;
       
  1020 	ty:= _0;
       
  1021 	while tt > _20 do
       
  1022 		begin
       
  1023 		if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
       
  1024 		or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
  1018 			begin
  1025 			begin
  1019 			if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
  1026 			Gear^.X:= Gear^.X + tx;
  1020 			or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
  1027 			Gear^.Y:= Gear^.Y + ty;
  1021 				begin
  1028 			Gear^.Elasticity:= tt;
  1022 				Gear^.X:= Gear^.X + tx;
  1029 			Gear^.doStep:= @doStepRopeWork;
  1023 				Gear^.Y:= Gear^.Y + ty;
  1030 			with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
  1024 				Gear^.Elasticity:= tt;
  1031 
  1025 				Gear^.doStep:= @doStepRopeWork;
  1032 			RemoveFromAmmo;
  1026 				with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump);
  1033 
  1027 
  1034 			tt:= _0;
  1028 				RemoveFromAmmo;
  1035 			exit
  1029 
       
  1030 				tt:= _0;
       
  1031 				exit
       
  1032 				end;
       
  1033 			tx:= tx + Gear^.dX + Gear^.dX;
       
  1034 			ty:= ty + Gear^.dY + Gear^.dY;
       
  1035 			tt:= tt - _2;
       
  1036 			end;
  1036 			end;
       
  1037 		tx:= tx + Gear^.dX + Gear^.dX;
       
  1038 		ty:= ty + Gear^.dY + Gear^.dY;
       
  1039 		tt:= tt - _2;
  1037 		end;
  1040 		end;
  1038 	end;
  1041 	end;
  1039 
  1042 
  1040 CheckCollision(Gear);
  1043 CheckCollision(Gear);
  1041 
  1044