hedgewars/uVisualGearsHandlers.pas
changeset 10859 d7e3abe3d5c2
parent 10858 bd281e854e02
child 11046 47a8c19ecb60
equal deleted inserted replaced
10858:bd281e854e02 10859:d7e3abe3d5c2
   871                 end
   871                 end
   872             end
   872             end
   873 end;
   873 end;
   874 
   874 
   875 ////////////////////////////////////////////////////////////////////////////////
   875 ////////////////////////////////////////////////////////////////////////////////
       
   876 var
       
   877     currwindbar: PVisualGear = nil;
       
   878 
       
   879 procedure doStepSmoothWindBarWork(Gear: PVisualGear; Steps: Longword);
       
   880 begin
       
   881     if currwindbar = Gear then
       
   882     begin
       
   883     inc(Gear^.Timer, Steps);
       
   884 
       
   885     while Gear^.Timer >= 10 do
       
   886         begin
       
   887         dec(Gear^.Timer, 10);
       
   888         if WindBarWidth < Gear^.Tag then
       
   889             inc(WindBarWidth)
       
   890         else if WindBarWidth > Gear^.Tag then
       
   891             dec(WindBarWidth);
       
   892         end;
       
   893     if cWindspeedf > Gear^.dAngle then
       
   894         begin
       
   895         cWindspeedf := cWindspeedf - Gear^.Angle*Steps;
       
   896         if cWindspeedf < Gear^.dAngle then cWindspeedf:= Gear^.dAngle;
       
   897         end
       
   898     else if cWindspeedf < Gear^.dAngle then
       
   899         begin
       
   900         cWindspeedf := cWindspeedf + Gear^.Angle*Steps;
       
   901         if cWindspeedf > Gear^.dAngle then cWindspeedf:= Gear^.dAngle;
       
   902         end;
       
   903     end;
       
   904 
       
   905     if ((WindBarWidth = Gear^.Tag) and (cWindspeedf = Gear^.dAngle)) or (currwindbar <> Gear) then
       
   906     begin
       
   907         if currwindbar = Gear then currwindbar:= nil;
       
   908         DeleteVisualGear(Gear)
       
   909     end
       
   910 end;
       
   911 
   876 procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword);
   912 procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword);
   877 begin
   913 begin
   878 inc(Gear^.Timer, Steps);
   914     currwindbar:= Gear;
   879 
   915     Gear^.doStep:= @doStepSmoothWindBarWork;
   880 while Gear^.Timer >= 10 do
   916     doStepSmoothWindBarWork(Gear, Steps)
   881     begin
       
   882     dec(Gear^.Timer, 10);
       
   883     if WindBarWidth < Gear^.Tag then
       
   884         inc(WindBarWidth)
       
   885     else if WindBarWidth > Gear^.Tag then
       
   886         dec(WindBarWidth);
       
   887     end;
       
   888 if cWindspeedf > Gear^.dAngle then
       
   889     begin
       
   890     cWindspeedf := cWindspeedf - Gear^.Angle*Steps;
       
   891     if cWindspeedf < Gear^.dAngle then cWindspeedf:= Gear^.dAngle;
       
   892     end
       
   893 else if cWindspeedf < Gear^.dAngle then
       
   894     begin
       
   895     cWindspeedf := cWindspeedf + Gear^.Angle*Steps;
       
   896     if cWindspeedf > Gear^.dAngle then cWindspeedf:= Gear^.dAngle;
       
   897     end;
       
   898 
       
   899 if (WindBarWidth = Gear^.Tag) and (cWindspeedf = Gear^.dAngle)  then
       
   900     DeleteVisualGear(Gear)
       
   901 end;
   917 end;
   902 ////////////////////////////////////////////////////////////////////////////////
   918 ////////////////////////////////////////////////////////////////////////////////
   903 procedure doStepStraightShot(Gear: PVisualGear; Steps: Longword);
   919 procedure doStepStraightShot(Gear: PVisualGear; Steps: Longword);
   904 begin
   920 begin
   905 Gear^.X:= Gear^.X + Gear^.dX * Steps;
   921 Gear^.X:= Gear^.X + Gear^.dX * Steps;