Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, StdCtrls, Menus;
- type
- TForm1 = class(TForm)
- Timer1: TTimer;
- Button1: TButton;
- Button3: TButton;
- MainMenu1: TMainMenu;
- Menu1: TMenuItem;
- Exit1: TMenuItem;
- Info1: TMenuItem;
- Copyright1: TMenuItem;
- Version1: TMenuItem;
- Edit1: TEdit;
- Edit2: TEdit;
- Button2: TButton;
- Label1: TLabel;
- Label2: TLabel;
- Timer2: TTimer;
- Timer3: TTimer;
- Timer4: TTimer;
- Timer5: TTimer;
- procedure Timer1Timer(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Exit1Click(Sender: TObject);
- procedure Copyright1Click(Sender: TObject);
- procedure Version1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Timer2Timer(Sender: TObject);
- procedure Timer3Timer(Sender: TObject);
- procedure Timer4Timer(Sender: TObject);
- procedure Timer5Timer(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- x,y,x1,y1,x2,y2,a1,b1,a2,b2,a3,b3,l,v,k,l1,l2,k1,k2,r2,run,res1,res2,res3,res4,res5,ugl,ugl2,ugl3,z:integer;
- grad,r:real;
- implementation
- {$R *.dfm}
- procedure robot(x,y,z,z1:integer;sender:tobject);
- begin
- //Çàòèðêà
- Form1.Canvas.Pen.Color:=Form1.Color;
- Form1.Canvas.Brush.Color:=Form1.Color;
- Form1.Canvas.Rectangle(0,0,550,200);
- Form1.Canvas.Rectangle(0,200,1000,800);
- // ---ÏÐÎÐÈÑÎÂÊÀ ÐÎÁÎÒÀ---
- Form1.Canvas.Pen.Color:=clRed;
- Form1.Canvas.Brush.Color:=Form1.Color;
- //Ïëàòôîðìà
- Form1.Canvas.Rectangle(x,y,x+50,y+50);
- Form1.Canvas.MoveTo(x+25,y-25);
- Form1.Canvas.LineTo(x+50,y);
- Form1.Canvas.MoveTo(x+25,y-25);
- //Áàøíÿ
- Form1.Canvas.MoveTo(a1,b1);
- Form1.Canvas.LineTo(a1,b1-25);
- Form1.Canvas.LineTo(a1+25,b1-25);
- Form1.Canvas.LineTo(a1+25,b1);
- Form1.Canvas.LineTo(a1,b1);
- //Äóëî
- Form1.Canvas.MoveTo(a2,b2);
- Form1.Canvas.LineTo(l,k);
- //Êëåøíè
- Form1.Canvas.MoveTo(l,k);
- Form1.Canvas.LineTo(l1,k1);
- Form1.Canvas.MoveTo(l,k);
- Form1.Canvas.LineTo(l2,k2);
- //Êîðçèíà
- form1.Canvas.Ellipse(754,410,804,390);
- form1.Canvas.MoveTo(754,400);
- form1.Canvas.LineTo(754,450);
- form1.Canvas.MoveTo(804,400);
- form1.Canvas.LineTo(804,450);
- form1.Canvas.MoveTo(804,450);
- form1.Canvas.LineTo(804,450);
- //Øàðèê
- form1.Canvas.Pen.Color:=clRed;
- form1.Canvas.Pen.Width:=2;
- form1.Canvas.Ellipse(x2,y2,x2+10,y2-10);
- end;
- procedure TForm1.Timer1Timer(Sender: TObject);
- begin
- robot(x,y,0,0,Form1);
- if (x<x2-10) and (run=150) then
- begin
- x:=x+5;
- a1:=a1+5;
- a2:=a2+5;
- l:=l+5;
- l1:=l1+5;
- l2:=l2+5;
- res1:=l1;
- res2:=k1;
- res3:=l2;
- res4:=k2;
- end;
- if (x>=x2-10) and (run=150) then
- begin
- l:=Round(a2+r*cos(ugl*grad));
- k:=Round(b2-r*sin(ugl*grad));
- l1:=Round(l+r2*cos(ugl2*grad));
- k1:=Round(k-r2*sin(ugl2*grad));
- l2:=Round(l+r2*cos(ugl3*grad));
- k2:=Round(k-r2*sin(ugl3*grad));
- res5:=k;
- end;
- if ugl=90 then
- run:=200;
- if z=1 then
- begin
- l:=Round(a2+r*cos(0*grad));
- k:=Round(b2-r*sin(0*grad));
- l1:=Round(l+r2*cos(45*grad));
- k1:=Round(k-r2*sin(45*grad));
- l2:=Round(l+r2*cos(315*grad));
- k2:=Round(k-r2*sin(315*grad));
- l1:=res1;
- k1:=res2;
- l2:=res3;
- k2:=res4;
- x2:=l+5;
- y2:=k+5;
- if y2<=450 then
- begin
- y2:=y2+1;
- end;
- if x<695 then
- begin
- x:=x+5;
- a1:=a1+5;
- a2:=a2+5;
- a3:=a3+5;
- res1:=res1+5;
- res3:=res3+5;
- l1:=l1+5;
- l2:=l2+5;
- l:=l+5;
- x2:=x2+5;
- end;
- if x>=695 then
- begin
- z:=2;
- y2:=y2+1;
- end;
- end;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- timer1.Enabled:=true;
- run:=150;
- end;
- procedure TForm1.FormActivate(Sender: TObject);
- begin
- ugl2:=45;
- ugl3:=90;
- a1:=100;
- b1:=375;
- a2:=112;
- b2:=363;
- a3:=143;
- b3:=363;
- x:=100;
- y:=400;
- x2:=400;
- y2:=300;
- r:=33;
- r2:=15;
- l:=145;
- grad:=2*pi/360;
- v:=90;
- k:=363;
- l1:=153;
- k1:=353;
- l2:=153;
- k2:=373;
- run:=0;
- ugl:=0;
- z:=0;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- z:=1;
- timer3.Enabled:=false;
- end;
- procedure TForm1.Exit1Click(Sender: TObject);
- begin
- close;
- end;
- procedure TForm1.Copyright1Click(Sender: TObject);
- begin
- showmessage('Copyright by Denis Ukhov (IT-7 230201, 2011 year)');
- end;
- procedure TForm1.Version1Click(Sender: TObject);
- begin
- showmessage('Tested Robot v2.2');
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- // X
- if x2<=700 then
- x2:=strtoint(Edit1.Text);
- if x2>=115 then
- x2:=strtoint(Edit1.Text);
- if x2>700 then
- begin
- x2:=400;
- showmessage('"X" íå ìîæåò áûòü ìåíüøå 115 è áîëüøå 700. "Õ"=400.');
- end;
- if x2<115 then
- begin
- x2:=400;
- showmessage('"X" íå ìîæåò áûòü ìåíüøå 115 è áîëüøå 700. "Õ"=400.');
- end;
- // Y
- if y2>=220 then
- y2:=strtoint(Edit2.Text);
- if y2<=340 then
- y2:=strtoint(Edit2.Text);
- if y2<220 then
- begin
- y2:=300;
- showmessage('"Y" íå ìîæåò áûòü ìåíüøå 220 è áîëüøå 340. "Ó"=300.');
- end;
- if y2>340 then
- begin
- y2:=300;
- showmessage('"Y" íå ìîæåò áûòü ìåíüøå 220 è áîëüøå 340. "Ó"=300.');
- end;
- end;
- procedure TForm1.Timer2Timer(Sender: TObject);
- begin
- if z=2 then
- begin
- if l<775 then
- l:=l+1;
- if l1<781 then
- l1:=l1+1;
- if l2<781 then
- l2:=l2+1;
- if a3<775 then
- a3:=a3+1;
- if x2<779 then
- x2:=x2+1;
- if l=775 then
- y2:=y2+1;
- if y2=450 then
- timer2.Enabled:=false;
- end;
- end;
- procedure TForm1.Timer3Timer(Sender: TObject);
- begin
- if x>=x2-10 then
- begin
- if ugl<90 then
- ugl:=ugl+1;
- if ugl2<135 then
- ugl2:=ugl2+1;
- if ugl3>45 then
- ugl3:=ugl3-1;
- end;
- end;
- procedure TForm1.Timer4Timer(Sender: TObject);
- begin
- if (ugl=90) and (k>=y2+5) then
- begin
- k:=k-1;
- k1:=k1-1;
- k2:=k2-1;
- end;
- if k=y2+5 then
- begin
- timer4.Enabled:=false;
- timer5.Enabled:=true;
- end;
- end;
- procedure TForm1.Timer5Timer(Sender: TObject);
- begin
- if k<=b2-33 then
- begin
- y2:=k-5;
- k:=k+1;
- k1:=k1+1;
- k2:=k2+1;
- end;
- if (k=b2-33) and (ugl=90) then
- z:=1;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement