hedgewars/GSHandlers.inc
changeset 1433 4af291d5d79c
parent 1417 210cb6b1b275
child 1435 d4b32ee3caa6
equal deleted inserted replaced
1432:ab212288d34d 1433:4af291d5d79c
   750 Gear^.Y:= Gear^.Y - Gear^.dY;
   750 Gear^.Y:= Gear^.Y - Gear^.dY;
   751 Gear^.Elasticity:= Gear^.Elasticity + _1;
   751 Gear^.Elasticity:= Gear^.Elasticity + _1;
   752 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   752 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
   753 DeleteCI(HHGear);
   753 DeleteCI(HHGear);
   754 if (HHGear^.State and gstMoving) <> 0 then
   754 if (HHGear^.State and gstMoving) <> 0 then
   755    if TestCollisionYwithGear(HHGear, 1) then
   755 if TestCollisionYwithGear(HHGear, 1) then
   756       begin
   756 	begin
   757       CheckHHDamage(HHGear);
   757 	CheckHHDamage(HHGear);
   758       HHGear^.dY:= _0;
   758 	HHGear^.dY:= _0;
   759       HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping);
   759 	HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping);
   760       end else
   760 	end else
   761       begin
   761 	begin
   762       if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
   762 	if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX);
   763       HHGear^.X:= HHGear^.X + HHGear^.dX;
   763 	HHGear^.X:= HHGear^.X + HHGear^.dX;
   764       HHGear^.Y:= HHGear^.Y + HHGear^.dY;
   764 	HHGear^.Y:= HHGear^.Y + HHGear^.dY;
   765       Gear^.X:= Gear^.X + HHGear^.dX;
   765 	Gear^.X:= Gear^.X + HHGear^.dX;
   766       Gear^.Y:= Gear^.Y + HHGear^.dY;
   766 	Gear^.Y:= Gear^.Y + HHGear^.dY;
   767       HHGear^.dY:= HHGear^.dY + cGravity;
   767 	HHGear^.dY:= HHGear^.dY + cGravity;
   768       tt:= Gear^.Elasticity;
   768 	tt:= Gear^.Elasticity;
   769       tx:= _0;
   769 	tx:= _0;
   770       ty:= _0;
   770 	ty:= _0;
   771       while tt > _20 do
   771 	while tt > _20 do
   772             begin
   772 		begin
   773             if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
   773 		if  TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX))
   774              or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
   774 		or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then
   775                 begin
   775 			begin
   776                 Gear^.X:= Gear^.X + tx;
   776 			Gear^.X:= Gear^.X + tx;
   777                 Gear^.Y:= Gear^.Y + ty;
   777 			Gear^.Y:= Gear^.Y + ty;
   778                 Gear^.Elasticity:= tt;
   778 			Gear^.Elasticity:= tt;
   779                 Gear^.doStep:= @doStepRopeWork;
   779 			Gear^.doStep:= @doStepRopeWork;
   780                 with HHGear^ do State:= State and not gstAttacking;
   780 			with HHGear^ do State:= State and not gstAttacking;
   781                 tt:= _0
   781 			tt:= _0
   782                 end;
   782 			end;
   783             tx:= tx + Gear^.dX + Gear^.dX;
   783 		tx:= tx + Gear^.dX + Gear^.dX;
   784             ty:= ty + Gear^.dY + Gear^.dY;
   784 		ty:= ty + Gear^.dY + Gear^.dY;
   785             tt:= tt - _2;
   785 		tt:= tt - _2;
   786             end;
   786 		end;
   787       end;
   787 	end;
   788 
   788 
   789 CheckCollision(Gear);
   789 CheckCollision(Gear);
   790 
   790 
   791 if (Gear^.State and gstCollision) <> 0 then
   791 if (Gear^.State and gstCollision) <> 0 then
   792 	begin
   792 	begin
   799 	if Gear^.Elasticity < _10 then
   799 	if Gear^.Elasticity < _10 then
   800 		Gear^.Elasticity:= _10000;
   800 		Gear^.Elasticity:= _10000;
   801 	end;
   801 	end;
   802 
   802 
   803 if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then
   803 if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then
   804    begin
   804 	begin
   805    with PHedgehog(Gear^.Hedgehog)^.Gear^ do
   805 	with PHedgehog(Gear^.Hedgehog)^.Gear^ do
   806         begin
   806 		begin
   807         State:= State and not gstAttacking;
   807 		State:= State and not gstAttacking;
   808         Message:= Message and not gm_Attack
   808 		Message:= Message and not gm_Attack
   809         end;
   809 		end;
   810    DeleteGear(Gear)
   810 	DeleteGear(Gear)
   811    end
   811 	end
   812 end;
   812 end;
   813 
   813 
   814 procedure doStepRope(Gear: PGear);
   814 procedure doStepRope(Gear: PGear);
   815 begin
   815 begin
   816 Gear^.dX:= - Gear^.dX;
   816 Gear^.dX:= - Gear^.dX;
  1077 Gear^.doStep:= @doStepIdle
  1077 Gear^.doStep:= @doStepIdle
  1078 end;
  1078 end;
  1079 
  1079 
  1080 ////////////////////////////////////////////////////////////////////////////////
  1080 ////////////////////////////////////////////////////////////////////////////////
  1081 procedure doStepFlame(Gear: PGear);
  1081 procedure doStepFlame(Gear: PGear);
  1082 begin
  1082 var cWindFactor: hwFloat;
  1083 AllInactive:= false;
  1083 begin
       
  1084 AllInactive:= false;
       
  1085 
  1084 if not TestCollisionYwithGear(Gear, 1) then
  1086 if not TestCollisionYwithGear(Gear, 1) then
  1085 	begin
  1087 	begin
  1086 	if hwAbs(Gear^.dX - cWindSpeed) > _0_1 then
  1088 	cWindFactor:= cWindSpeed * 270;
  1087 		Gear^.dX:= (Gear^.dX - cWindSpeed) * _0_5 + cWindSpeed;
  1089 	
       
  1090 	if hwAbs(Gear^.dX - cWindFactor) > _0_01 then
       
  1091 		Gear^.dX:= (Gear^.dX - cWindFactor) * _0_998 + cWindFactor;
  1088 
  1092 
  1089 	Gear^.dY:= Gear^.dY + cGravity;
  1093 	Gear^.dY:= Gear^.dY + cGravity;
  1090 	if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995;
  1094 	if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995;
  1091 	
  1095 	
  1092 	Gear^.X:= Gear^.X + Gear^.dX;
  1096 	Gear^.X:= Gear^.X + Gear^.dX;