Advertisement
MadCortez

Untitled

Apr 7th, 2021
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 4.44 KB | None | 0 0
  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls, Vcl.Grids,
  8.   Vcl.Imaging.GIFImg, Vcl.ExtCtrls, JPEG, Vcl.Imaging.pngimage;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     MainMenu1: TMainMenu;
  13.     AboutButton: TMenuItem;
  14.     TimerPutin: TTimer;
  15.     TimerLuka: TTimer;
  16.     TimerZele: TTimer;
  17.     ImageBegPutin: TImage;
  18.     ImagePutin: TImage;
  19.     ImageBegLuka: TImage;
  20.     ImageBegZele: TImage;
  21.     ImageLuka: TImage;
  22.     ImageZele: TImage;
  23.     procedure AboutButtonClick(Sender: TObject);
  24.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  25.     procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  26.     procedure TimerPutinTimer(Sender: TObject);
  27.     procedure AnimatePutin;
  28.     procedure AnimateLuka;
  29.     procedure AnimateZele;
  30.     procedure TimerLukaTimer(Sender: TObject);
  31.     procedure TimerZeleTimer(Sender: TObject);
  32.   private
  33.     { Private declarations }
  34.   public
  35.     { Public declarations }
  36.   end;
  37.  
  38. {$R *.dfm}
  39.  
  40. var
  41.   Form1: TForm1;
  42.   Place: array[1..3] of String;
  43.   NumPlace: Byte;
  44.   Ans: String;
  45.  
  46. implementation
  47.  
  48. procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  49. begin
  50.    CanClose := MessageDlg('Вы уверены, что хотите выйти из программы?' +
  51.       #10#13 + 'Все несохраненные данные будут утеряны.',
  52.       mtConfirmation, [mbYes, mbNo], 0) = mrYes;
  53. end;
  54.  
  55. procedure TForm1.AboutButtonClick(Sender: TObject);
  56. var
  57.    Task: String;
  58. begin
  59.    Task := 'Политики' + #10#13;
  60.    Task := Task + 'По нажатию "Enter" начинают движение сначала' + #10#13;
  61.    Task := Task + 'Автор - Пестунов Илья, гр. 051007';
  62.    MessageDlg(Task, mtInformation, [mbOK], 0);
  63. end;
  64.  
  65. procedure TForm1.AnimatePutin;
  66. begin
  67.    if ImagePutin.Enabled then
  68.    begin
  69.    ImagePutin.Left := ImagePutin.Left + Random(3) + 5;
  70.    if ImagePutin.Left + 50 >= ImageBegPutin.Width then
  71.    begin
  72.       Inc(NumPlace);
  73.       Place[NumPlace] := 'Путин занял ' + IntToStr(NumPlace) + ' место!';
  74.       TimerPutin.Enabled := False;
  75.       ImagePutin.Enabled := False;
  76.       if NumPlace = 3 then
  77.       begin
  78.          Ans := Place[1] + #10#13 + Place[2] + #10#13 + Place[3] + #10#13;
  79.          ShowMessage(Ans);
  80.       end;
  81.    end;
  82.    end;
  83. end;
  84.  
  85. procedure TForm1.AnimateLuka;
  86. begin
  87.    if ImageLuka.Enabled then
  88.    begin
  89.    ImageLuka.Left := ImageLuka.Left + Random(3) + 5;
  90.    if ImageLuka.Left + 50 >= ImageBegLuka.Width then
  91.    begin
  92.       Inc(NumPlace);
  93.       Place[NumPlace] := 'Лукашенко занял ' + IntToStr(NumPlace) + ' место!';
  94.       TimerLuka.Enabled := False;
  95.       ImageLuka.Enabled := False;
  96.       if NumPlace = 3 then
  97.       begin
  98.          Ans := Place[1] + #10#13 + Place[2] + #10#13 + Place[3] + #10#13;
  99.          ShowMessage(Ans);
  100.       end;
  101.    end;
  102.    end;
  103. end;
  104.  
  105. procedure TForm1.AnimateZele;
  106. begin
  107.    if ImageZele.Enabled then
  108.    begin
  109.    ImageZele.Left := ImageZele.Left + Random(3) + 5;
  110.    if ImageZele.Left + 50 >= ImageBegZele.Width then
  111.    begin
  112.       Inc(NumPlace);
  113.       Place[NumPlace] := 'Зеленский занял ' + IntToStr(NumPlace) + ' место!';
  114.       TimerZele.Enabled := False;
  115.       ImageZele.Enabled := False;
  116.       if NumPlace = 3 then
  117.       begin
  118.          Ans := Place[1] + #10#13 + Place[2] + #10#13 + Place[3] + #10#13;
  119.          ShowMessage(Ans);
  120.       end;
  121.    end;
  122.    end;
  123. end;
  124.  
  125. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  126.   Shift: TShiftState);
  127. begin
  128.    if Key = VK_RETURN then
  129.    begin
  130.       NumPlace := 0;
  131.       ImageZele.Left := 32;
  132.       ImagePutin.Left := 32;
  133.       ImageLuka.Left := 32;
  134.       ImageZele.Enabled := True;
  135.       ImagePutin.Enabled := True;
  136.       ImageLuka.Enabled := True;
  137.       TimerPutin.Enabled := Not TimerPutin.Enabled;
  138.       TimerLuka.Enabled := Not TimerLuka.Enabled;
  139.       TimerZele.Enabled := Not TimerZele.Enabled;
  140.    end;
  141. end;
  142.  
  143. procedure TForm1.TimerLukaTimer(Sender: TObject);
  144. begin
  145.    TimerLuka.Interval := Random(10) + 20;
  146.    AnimateLuka;
  147. end;
  148.  
  149. procedure TForm1.TimerPutinTimer(Sender: TObject);
  150. begin
  151.    TimerPutin.Interval := Random(10) + 20;
  152.    AnimatePutin;
  153. end;
  154.  
  155. procedure TForm1.TimerZeleTimer(Sender: TObject);
  156. begin
  157.    TimerZele.Interval := Random(10) + 20;
  158.    AnimateZele;
  159. end;
  160.  
  161. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement