Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Main;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls, Vcl.Grids,
- Vcl.Imaging.GIFImg, Vcl.ExtCtrls, JPEG, Vcl.Imaging.pngimage;
- type
- TForm1 = class(TForm)
- MainMenu1: TMainMenu;
- AboutButton: TMenuItem;
- TimerPutin: TTimer;
- TimerLuka: TTimer;
- TimerZele: TTimer;
- ImageBegPutin: TImage;
- ImagePutin: TImage;
- ImageBegLuka: TImage;
- ImageBegZele: TImage;
- ImageLuka: TImage;
- ImageZele: TImage;
- procedure AboutButtonClick(Sender: TObject);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
- procedure TimerPutinTimer(Sender: TObject);
- procedure AnimatePutin;
- procedure AnimateLuka;
- procedure AnimateZele;
- procedure TimerLukaTimer(Sender: TObject);
- procedure TimerZeleTimer(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- {$R *.dfm}
- var
- Form1: TForm1;
- Place: array[1..3] of String;
- NumPlace: Byte;
- Ans: String;
- implementation
- procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- begin
- CanClose := MessageDlg('Вы уверены, что хотите выйти из программы?' +
- #10#13 + 'Все несохраненные данные будут утеряны.',
- mtConfirmation, [mbYes, mbNo], 0) = mrYes;
- end;
- procedure TForm1.AboutButtonClick(Sender: TObject);
- var
- Task: String;
- begin
- Task := 'Политики' + #10#13;
- Task := Task + 'По нажатию "Enter" начинают движение сначала' + #10#13;
- Task := Task + 'Автор - Пестунов Илья, гр. 051007';
- MessageDlg(Task, mtInformation, [mbOK], 0);
- end;
- procedure TForm1.AnimatePutin;
- begin
- if ImagePutin.Enabled then
- begin
- ImagePutin.Left := ImagePutin.Left + Random(3) + 5;
- if ImagePutin.Left + 50 >= ImageBegPutin.Width then
- begin
- Inc(NumPlace);
- Place[NumPlace] := 'Путин занял ' + IntToStr(NumPlace) + ' место!';
- TimerPutin.Enabled := False;
- ImagePutin.Enabled := False;
- if NumPlace = 3 then
- begin
- Ans := Place[1] + #10#13 + Place[2] + #10#13 + Place[3] + #10#13;
- ShowMessage(Ans);
- end;
- end;
- end;
- end;
- procedure TForm1.AnimateLuka;
- begin
- if ImageLuka.Enabled then
- begin
- ImageLuka.Left := ImageLuka.Left + Random(3) + 5;
- if ImageLuka.Left + 50 >= ImageBegLuka.Width then
- begin
- Inc(NumPlace);
- Place[NumPlace] := 'Лукашенко занял ' + IntToStr(NumPlace) + ' место!';
- TimerLuka.Enabled := False;
- ImageLuka.Enabled := False;
- if NumPlace = 3 then
- begin
- Ans := Place[1] + #10#13 + Place[2] + #10#13 + Place[3] + #10#13;
- ShowMessage(Ans);
- end;
- end;
- end;
- end;
- procedure TForm1.AnimateZele;
- begin
- if ImageZele.Enabled then
- begin
- ImageZele.Left := ImageZele.Left + Random(3) + 5;
- if ImageZele.Left + 50 >= ImageBegZele.Width then
- begin
- Inc(NumPlace);
- Place[NumPlace] := 'Зеленский занял ' + IntToStr(NumPlace) + ' место!';
- TimerZele.Enabled := False;
- ImageZele.Enabled := False;
- if NumPlace = 3 then
- begin
- Ans := Place[1] + #10#13 + Place[2] + #10#13 + Place[3] + #10#13;
- ShowMessage(Ans);
- end;
- end;
- end;
- end;
- procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- if Key = VK_RETURN then
- begin
- NumPlace := 0;
- ImageZele.Left := 32;
- ImagePutin.Left := 32;
- ImageLuka.Left := 32;
- ImageZele.Enabled := True;
- ImagePutin.Enabled := True;
- ImageLuka.Enabled := True;
- TimerPutin.Enabled := Not TimerPutin.Enabled;
- TimerLuka.Enabled := Not TimerLuka.Enabled;
- TimerZele.Enabled := Not TimerZele.Enabled;
- end;
- end;
- procedure TForm1.TimerLukaTimer(Sender: TObject);
- begin
- TimerLuka.Interval := Random(10) + 20;
- AnimateLuka;
- end;
- procedure TForm1.TimerPutinTimer(Sender: TObject);
- begin
- TimerPutin.Interval := Random(10) + 20;
- AnimatePutin;
- end;
- procedure TForm1.TimerZeleTimer(Sender: TObject);
- begin
- TimerZele.Interval := Random(10) + 20;
- AnimateZele;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement