Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit MainMenuUnit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
- Vcl.StdCtrls, Vcl.Buttons, Vcl.Imaging.jpeg, Vcl.Imaging.GIFImg, Vcl.ComCtrls;
- type
- TMainForm = class(TForm)
- LeftCloudImg: TImage;
- RightCloudImg: TImage;
- TimerOfLeft: TTimer;
- TimerOfRight: TTimer;
- StartButton: TBitBtn;
- RainbowImg: TImage;
- RainImg: TImage;
- Image1: TImage;
- TimerOfRain: TTimer;
- procedure TimerOfLeftTimer(Sender: TObject);
- procedure TimerOfRightTimer(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure StartButtonClick(Sender: TObject);
- procedure TimerOfRainTimer(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- MainForm: TMainForm;
- implementation
- {$R *.dfm}
- var
- Sign: Integer;
- procedure TMainForm.StartButtonClick(Sender: TObject);
- begin
- TimerOfLeft.Enabled := not TimerOfLeft.Enabled;
- TimerOfRight.Enabled := not TimerOfRight.Enabled;
- TimerOfRain.Enabled := not TimerOfRain.Enabled;
- if TimerOfLeft.Enabled then
- StartButton.Caption := 'Прекратить суету'
- else
- StartButton.Caption := 'Навести суету'
- end;
- procedure TMainForm.FormCreate(Sender: TObject);
- begin
- Sign := 1;
- RightCloudImg.Parent.DoubleBuffered := True;
- LeftCloudImg.Parent.DoubleBuffered := True;
- RainImg.Parent.DoubleBuffered := True;
- end;
- procedure TMainForm.TimerOfLeftTimer(Sender: TObject);
- begin
- LeftCloudImg.Left := LeftCloudImg.Left + 1;
- end;
- procedure TMainForm.TimerOfRainTimer(Sender: TObject);
- const
- EXPANSION = 2;
- CONTRACTION = 4;
- RAIN_TRANSLATION = 15;
- begin
- if RainImg.Visible then
- begin
- Sign := -Sign;
- RainImg.Top := RainImg.Top + RAIN_TRANSLATION * sign;
- RainImg.Left := RightCloudImg.Left;
- RainImg.Width := RainImg.Width + EXPANSION;
- if RightCloudImg.Left - LeftCloudImg.Left < 0 then
- begin
- RainImg.Left := LeftCloudImg.Left;
- RainImg.Width := RainImg.Width - CONTRACTION;
- end;
- end;
- end;
- procedure TMainForm.TimerOfRightTimer(Sender: TObject);
- const
- CLOUD_WIDTH = 345;
- var
- IsOverlapped: Boolean;
- begin
- RightCloudImg.Left := RightCloudImg.Left - 1;
- RainbowImg.Visible := (RightCloudImg.Left - LeftCloudImg.Left + CLOUD_WIDTH) < 0;
- RainImg.Visible := (RightCloudImg.Left - LeftCloudImg.Left < CLOUD_WIDTH) and
- ((RightCloudImg.Left - LeftCloudImg.Left + CLOUD_WIDTH) > 0);
- if RightCloudImg.Left = 0 then
- begin
- LeftCloudImg.Left := 0;
- RightCloudImg.Left := 764;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement