Advertisement
Vanya_Shestakov

Untitled

Mar 14th, 2021
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.80 KB | None | 0 0
  1. unit MainMenuUnit;
  2. interface
  3. uses
  4.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  5.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
  6.   Vcl.StdCtrls, Vcl.Buttons, Vcl.Imaging.jpeg, Vcl.Imaging.GIFImg, Vcl.ComCtrls;
  7.  
  8. type
  9.   TMainForm = class(TForm)
  10.     LeftCloudImg: TImage;
  11.     RightCloudImg: TImage;
  12.     TimerOfLeft: TTimer;
  13.     TimerOfRight: TTimer;
  14.     StartButton: TBitBtn;
  15.     RainbowImg: TImage;
  16.     RainImg: TImage;
  17.     Image1: TImage;
  18.     TimerOfRain: TTimer;
  19.     procedure TimerOfLeftTimer(Sender: TObject);
  20.     procedure TimerOfRightTimer(Sender: TObject);
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure StartButtonClick(Sender: TObject);
  23.     procedure TimerOfRainTimer(Sender: TObject);
  24.   private
  25.     { Private declarations }
  26.   public
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.   MainForm: TMainForm;
  32.  
  33. implementation
  34. {$R *.dfm}
  35. var
  36.     Sign: Integer;
  37.  
  38. procedure TMainForm.StartButtonClick(Sender: TObject);
  39. begin
  40.     TimerOfLeft.Enabled := not TimerOfLeft.Enabled;
  41.     TimerOfRight.Enabled := not TimerOfRight.Enabled;
  42.     TimerOfRain.Enabled := not TimerOfRain.Enabled;
  43.     if TimerOfLeft.Enabled then
  44.         StartButton.Caption := 'Прекратить суету'
  45.     else
  46.         StartButton.Caption := 'Навести суету'
  47. end;
  48.  
  49. procedure TMainForm.FormCreate(Sender: TObject);
  50. begin
  51.     Sign := 1;
  52.     RightCloudImg.Parent.DoubleBuffered := True;
  53.     LeftCloudImg.Parent.DoubleBuffered := True;
  54.     RainImg.Parent.DoubleBuffered := True;
  55. end;
  56.  
  57. procedure TMainForm.TimerOfLeftTimer(Sender: TObject);
  58. begin
  59.     LeftCloudImg.Left := LeftCloudImg.Left + 1;
  60. end;
  61.  
  62. procedure TMainForm.TimerOfRainTimer(Sender: TObject);
  63. const
  64.     EXPANSION = 2;
  65.     CONTRACTION = 4;
  66.     RAIN_TRANSLATION = 15;
  67. begin
  68.     if RainImg.Visible then
  69.     begin
  70.         Sign := -Sign;
  71.         RainImg.Top := RainImg.Top + RAIN_TRANSLATION * sign;
  72.         RainImg.Left :=  RightCloudImg.Left;
  73.         RainImg.Width := RainImg.Width + EXPANSION;
  74.         if RightCloudImg.Left - LeftCloudImg.Left < 0 then
  75.         begin
  76.             RainImg.Left :=   LeftCloudImg.Left;
  77.             RainImg.Width := RainImg.Width - CONTRACTION;
  78.         end;
  79.     end;
  80. end;
  81.  
  82. procedure TMainForm.TimerOfRightTimer(Sender: TObject);
  83. const
  84.     CLOUD_WIDTH = 345;
  85. var
  86.     IsOverlapped: Boolean;
  87. begin
  88.     RightCloudImg.Left := RightCloudImg.Left - 1;
  89.     RainbowImg.Visible := (RightCloudImg.Left - LeftCloudImg.Left + CLOUD_WIDTH) < 0;
  90.     RainImg.Visible := (RightCloudImg.Left - LeftCloudImg.Left < CLOUD_WIDTH) and
  91.     ((RightCloudImg.Left - LeftCloudImg.Left + CLOUD_WIDTH) > 0);
  92.     if RightCloudImg.Left = 0 then
  93.     begin
  94.         LeftCloudImg.Left := 0;
  95.         RightCloudImg.Left := 764;
  96.     end;
  97. end;
  98.  
  99. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement