dizballanze

жив цел орел

Nov 7th, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 5.20 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, ExtCtrls, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     ListBox1: TListBox;
  12.     ListBox2: TListBox;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Label3: TLabel;
  16.     Label4: TLabel;
  17.     Label5: TLabel;
  18.     Label6: TLabel;
  19.     Label7: TLabel;
  20.     Label8: TLabel;
  21.     Label9: TLabel;
  22.     Label10: TLabel;
  23.     Button1: TButton;
  24.     System: TTimer;
  25.     Generator1: TTimer;
  26.     Generator2: TTimer;
  27.     Handler1: TTimer;
  28.     Handler2: TTimer;
  29.     Sputnik: TTimer;
  30.     Label11: TLabel;
  31.     Label12: TLabel;
  32.     Label13: TLabel;
  33.     Label14: TLabel;
  34.     procedure SystemTimer(Sender: TObject);
  35.     procedure Button1Click(Sender: TObject);
  36.     procedure Generator1Timer(Sender: TObject);
  37.     procedure SputnikTimer(Sender: TObject);
  38.     procedure Handler1Timer(Sender: TObject);
  39.     procedure Generator2Timer(Sender: TObject);
  40.     procedure Handler2Timer(Sender: TObject);
  41.   private
  42.     { Private declarations }
  43.   public
  44.     { Public declarations }
  45.   end;
  46.  
  47. var
  48.   Form1: TForm1;
  49.   work: boolean;
  50.   buffer1: array[1..2] of boolean;
  51.   buffer2: array[1..2] of boolean;
  52.   sputnik_free: boolean;
  53.   sputnik_time: integer;
  54.  
  55. implementation
  56.  
  57. uses Math;
  58.  
  59. {$R *.dfm}
  60.  
  61. procedure CalculateSputnik();
  62. var
  63.   count: integer;
  64. begin
  65.   count := StrToInt(Form1.Label8.Caption);
  66.   count := count + 1;
  67.   Form1.Label8.Caption := IntToStr(count);
  68.   if (sputnik_free = false) then
  69.   begin
  70.     count := StrToInt(Form1.Label10.Caption);
  71.     count := count + 1;
  72.     Form1.Label10.Caption := IntToStr(count);
  73.   end else
  74.   begin
  75.     sputnik_free := false;
  76.     Form1.Sputnik.Interval := RandomRange(50,150);
  77.     sputnik_time := sputnik_time + Form1.Sputnik.Interval;
  78.     Form1.Sputnik.Enabled := true;
  79.   end;
  80. end;
  81.  
  82. procedure TForm1.SystemTimer(Sender: TObject);
  83. begin
  84.    work:=false;
  85.    label12.Caption := FloatToStr(StrToInt(Label10.Caption)/ 60);
  86.    Label14.Caption := FloatToStr((sputnik_time / 600000) * 100);
  87. end;
  88.  
  89. procedure TForm1.Button1Click(Sender: TObject);
  90. begin
  91.   work:=true;
  92.   System.Enabled := true;
  93.   Generator1.Interval := RandomRange(70, 130);
  94.   Generator2.Interval := RandomRange(70, 130);
  95.   Generator1.Enabled := true;
  96.   Generator2.Enabled := true;
  97.   buffer1[1] := false;
  98.   buffer1[2] := false;
  99.   buffer2[1] := false;
  100.   buffer2[2] := false;
  101.   sputnik_free := true;
  102.   Label8.Caption := '0';
  103.   Label10.Caption := '0';
  104.   sputnik_time := 0;
  105. end;
  106.  
  107. procedure TForm1.Generator1Timer(Sender: TObject);
  108. begin
  109.     Generator1.Interval := RandomRange(70, 130);
  110.     if (work=false) then
  111.       Generator1.Enabled := false
  112.     else if ((buffer1[1] = true) AND (buffer1[2] = true)) then
  113.     begin
  114.       ListBox1.Items.Add('Iaeao ioi?aaeai ia niooieeiao? eeie?');
  115.       CalculateSputnik;
  116.     end
  117.     else if (buffer1[1]=false) then
  118.     begin
  119.       buffer1[1] := true;
  120.       Label3.Color := clRed;
  121.       ListBox1.Items.Add('Iaeao caianai a 1 ?aaeno?');
  122.       if (Handler1.Enabled = false) then
  123.          Handler1.Enabled := true;
  124.     end else
  125.     begin
  126.       buffer1[2] := true;
  127.       Label4.Color := clRed;
  128.       ListBox1.Items.Add('Iaeao caianai a 2 ?aaeno?');
  129.       if (Handler1.Enabled = false) then
  130.       begin
  131.          Handler1.Enabled := true;
  132.       end;
  133.     end;
  134. end;
  135.  
  136. procedure TForm1.SputnikTimer(Sender: TObject);
  137. begin
  138.   sputnik_free := true;
  139.   Sputnik.Enabled := false;
  140. end;
  141.  
  142. procedure TForm1.Handler1Timer(Sender: TObject);
  143. begin
  144.   if (buffer1[2] = true) then
  145.   begin
  146.     buffer1[2] := false;
  147.     Label4.Color := clGreen;
  148.     ListBox1.Items.Add('Cia?aiea 2 ?aaeno?a ia?aaioaii');
  149.   end
  150.   else if (buffer1[1] = true) then
  151.   begin
  152.     buffer1[1] := false;
  153.     Label3.Color := clGreen;
  154.     ListBox1.Items.Add('Cia?aiea 1 ?aaeno?a ia?aaioaii');
  155.   end;
  156.  
  157.   if ((buffer1[1] = false) AND (buffer1[2] = false)) then
  158.     Handler1.Enabled := false;
  159.  
  160. end;
  161.  
  162. procedure TForm1.Generator2Timer(Sender: TObject);
  163. begin
  164.     Generator2.Interval := RandomRange(70, 130);
  165.     if (work=false) then
  166.       Generator2.Enabled := false
  167.     else if ((buffer2[1] = true) AND (buffer2[2] = true)) then
  168.     begin
  169.       ListBox2.Items.Add('Iaeao ioi?aaeai ia niooieeiao? eeie?');
  170.       CalculateSputnik;
  171.     end
  172.     else if (buffer2[1]=false) then
  173.     begin
  174.       buffer2[1] := true;
  175.       Label5.Color := clRed;
  176.       ListBox2.Items.Add('Iaeao caianai a 1 ?aaeno?');
  177.       if (Handler2.Enabled = false) then
  178.          Handler2.Enabled := true;
  179.     end else
  180.     begin
  181.       buffer2[2] := true;
  182.       Label6.Color := clRed;
  183.       ListBox2.Items.Add('Iaeao caianai a 2 ?aaeno?');
  184.       if (Handler2.Enabled = false) then
  185.       begin
  186.          Handler2.Enabled := true;
  187.       end;
  188.     end;
  189. end;
  190.  
  191. procedure TForm1.Handler2Timer(Sender: TObject);
  192. begin
  193.   if (buffer2[2] = true) then
  194.   begin
  195.     buffer2[2] := false;
  196.     Label6.Color := clGreen;
  197.     ListBox2.Items.Add('Cia?aiea 2 ?aaeno?a ia?aaioaii');
  198.   end
  199.   else if (buffer2[1] = true) then
  200.   begin
  201.     buffer2[1] := false;
  202.     Label5.Color := clGreen;
  203.     ListBox2.Items.Add('Cia?aiea 1 ?aaeno?a ia?aaioaii');
  204.   end;
  205.  
  206.   if ((buffer2[1] = false) AND (buffer2[2] = false)) then
  207.     Handler2.Enabled := false;
  208. end;
  209.  
  210. end.
  211.  
Advertisement
Add Comment
Please, Sign In to add comment