Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 6.01 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, Menus;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Timer1: TTimer;
  12.     Button1: TButton;
  13.     Button3: TButton;
  14.     MainMenu1: TMainMenu;
  15.     Menu1: TMenuItem;
  16.     Exit1: TMenuItem;
  17.     Info1: TMenuItem;
  18.     Copyright1: TMenuItem;
  19.     Version1: TMenuItem;
  20.     Edit1: TEdit;
  21.     Edit2: TEdit;
  22.     Button2: TButton;
  23.     Label1: TLabel;
  24.     Label2: TLabel;
  25.     Timer2: TTimer;
  26.     Timer3: TTimer;
  27.     Timer4: TTimer;
  28.     Timer5: TTimer;
  29.     procedure Timer1Timer(Sender: TObject);
  30.     procedure Button1Click(Sender: TObject);
  31.     procedure FormActivate(Sender: TObject);
  32.     procedure Button3Click(Sender: TObject);
  33.     procedure Exit1Click(Sender: TObject);
  34.     procedure Copyright1Click(Sender: TObject);
  35.     procedure Version1Click(Sender: TObject);
  36.     procedure Button2Click(Sender: TObject);
  37.     procedure Timer2Timer(Sender: TObject);
  38.     procedure Timer3Timer(Sender: TObject);
  39.     procedure Timer4Timer(Sender: TObject);
  40.     procedure Timer5Timer(Sender: TObject);
  41.  
  42.   private
  43.     { Private declarations }
  44.   public
  45.     { Public declarations }
  46.   end;
  47.  
  48. var
  49.   Form1: TForm1;
  50.   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;
  51.   grad,r:real;
  52.  
  53. implementation
  54.  
  55. {$R *.dfm}
  56.  
  57. procedure robot(x,y,z,z1:integer;sender:tobject);
  58. begin
  59. //Çàòèðêà
  60. Form1.Canvas.Pen.Color:=Form1.Color;
  61. Form1.Canvas.Brush.Color:=Form1.Color;
  62. Form1.Canvas.Rectangle(0,0,550,200);
  63. Form1.Canvas.Rectangle(0,200,1000,800);
  64.  
  65. // ---ÏÐÎÐÈÑÎÂÊÀ ÐÎÁÎÒÀ---
  66.  
  67. Form1.Canvas.Pen.Color:=clRed;
  68. Form1.Canvas.Brush.Color:=Form1.Color;
  69.  
  70. //Ïëàòôîðìà
  71. Form1.Canvas.Rectangle(x,y,x+50,y+50);
  72. Form1.Canvas.MoveTo(x+25,y-25);
  73. Form1.Canvas.LineTo(x+50,y);
  74. Form1.Canvas.MoveTo(x+25,y-25);
  75. //Áàøíÿ
  76. Form1.Canvas.MoveTo(a1,b1);
  77. Form1.Canvas.LineTo(a1,b1-25);
  78. Form1.Canvas.LineTo(a1+25,b1-25);
  79. Form1.Canvas.LineTo(a1+25,b1);
  80. Form1.Canvas.LineTo(a1,b1);
  81. //Äóëî
  82. Form1.Canvas.MoveTo(a2,b2);
  83. Form1.Canvas.LineTo(l,k);
  84. //Êëåøíè
  85. Form1.Canvas.MoveTo(l,k);
  86. Form1.Canvas.LineTo(l1,k1);
  87. Form1.Canvas.MoveTo(l,k);
  88. Form1.Canvas.LineTo(l2,k2);
  89. //Êîðçèíà
  90. form1.Canvas.Ellipse(754,410,804,390);
  91. form1.Canvas.MoveTo(754,400);
  92. form1.Canvas.LineTo(754,450);
  93. form1.Canvas.MoveTo(804,400);
  94. form1.Canvas.LineTo(804,450);
  95. form1.Canvas.MoveTo(804,450);
  96. form1.Canvas.LineTo(804,450);
  97. //Øàðèê
  98. form1.Canvas.Pen.Color:=clRed;
  99. form1.Canvas.Pen.Width:=2;
  100. form1.Canvas.Ellipse(x2,y2,x2+10,y2-10);
  101. end;
  102.  
  103. procedure TForm1.Timer1Timer(Sender: TObject);
  104. begin
  105. robot(x,y,0,0,Form1);
  106.  
  107. if (x<x2-10) and (run=150) then
  108. begin
  109. x:=x+5;
  110. a1:=a1+5;
  111. a2:=a2+5;
  112. l:=l+5;
  113. l1:=l1+5;
  114. l2:=l2+5;
  115. res1:=l1;
  116. res2:=k1;
  117. res3:=l2;
  118. res4:=k2;
  119. end;
  120.  
  121. if (x>=x2-10) and (run=150) then
  122. begin
  123. l:=Round(a2+r*cos(ugl*grad));
  124. k:=Round(b2-r*sin(ugl*grad));
  125. l1:=Round(l+r2*cos(ugl2*grad));
  126. k1:=Round(k-r2*sin(ugl2*grad));
  127. l2:=Round(l+r2*cos(ugl3*grad));
  128. k2:=Round(k-r2*sin(ugl3*grad));
  129. res5:=k;
  130. end;
  131. if ugl=90 then
  132. run:=200;
  133.  
  134. if z=1 then
  135. begin
  136. l:=Round(a2+r*cos(0*grad));
  137. k:=Round(b2-r*sin(0*grad));
  138. l1:=Round(l+r2*cos(45*grad));
  139. k1:=Round(k-r2*sin(45*grad));
  140. l2:=Round(l+r2*cos(315*grad));
  141. k2:=Round(k-r2*sin(315*grad));
  142. l1:=res1;
  143. k1:=res2;
  144. l2:=res3;
  145. k2:=res4;
  146. x2:=l+5;
  147. y2:=k+5;
  148.  
  149. if y2<=450 then
  150. begin
  151. y2:=y2+1;
  152. end;
  153.  
  154. if x<695 then
  155. begin
  156. x:=x+5;
  157. a1:=a1+5;
  158. a2:=a2+5;
  159. a3:=a3+5;
  160. res1:=res1+5;
  161. res3:=res3+5;
  162. l1:=l1+5;
  163. l2:=l2+5;
  164. l:=l+5;
  165. x2:=x2+5;
  166. end;
  167.  
  168. if x>=695 then
  169. begin
  170. z:=2;
  171. y2:=y2+1;
  172. end;
  173. end;
  174. end;
  175.  
  176. procedure TForm1.Button1Click(Sender: TObject);
  177. begin
  178. timer1.Enabled:=true;
  179. run:=150;
  180. end;
  181.  
  182. procedure TForm1.FormActivate(Sender: TObject);
  183. begin
  184. ugl2:=45;
  185. ugl3:=90;
  186. a1:=100;
  187. b1:=375;
  188. a2:=112;
  189. b2:=363;
  190. a3:=143;
  191. b3:=363;
  192. x:=100;
  193. y:=400;
  194. x2:=400;
  195. y2:=300;
  196. r:=33;
  197. r2:=15;
  198. l:=145;
  199. grad:=2*pi/360;
  200. v:=90;
  201. k:=363;
  202. l1:=153;
  203. k1:=353;
  204. l2:=153;
  205. k2:=373;
  206. run:=0;
  207. ugl:=0;
  208. z:=0;
  209. end;
  210.  
  211. procedure TForm1.Button3Click(Sender: TObject);
  212. begin
  213. z:=1;
  214. timer3.Enabled:=false;
  215. end;
  216.  
  217. procedure TForm1.Exit1Click(Sender: TObject);
  218. begin
  219. close;
  220. end;
  221.  
  222. procedure TForm1.Copyright1Click(Sender: TObject);
  223. begin
  224. showmessage('Copyright by Denis Ukhov (IT-7 230201, 2011 year)');
  225. end;
  226.  
  227. procedure TForm1.Version1Click(Sender: TObject);
  228. begin
  229. showmessage('Tested Robot v2.2');
  230. end;
  231.  
  232. procedure TForm1.Button2Click(Sender: TObject);
  233. begin
  234. // X
  235. if x2<=700 then
  236. x2:=strtoint(Edit1.Text);
  237. if x2>=115 then
  238. x2:=strtoint(Edit1.Text);
  239. if x2>700 then
  240. begin
  241. x2:=400;
  242. showmessage('"X" íå ìîæåò áûòü ìåíüøå 115 è áîëüøå 700. "Õ"=400.');
  243. end;
  244. if x2<115 then
  245. begin
  246. x2:=400;
  247. showmessage('"X" íå ìîæåò áûòü ìåíüøå 115 è áîëüøå 700. "Õ"=400.');
  248. end;
  249. // Y
  250. if y2>=220 then
  251. y2:=strtoint(Edit2.Text);
  252. if y2<=340 then
  253. y2:=strtoint(Edit2.Text);
  254. if y2<220 then
  255. begin
  256. y2:=300;
  257. showmessage('"Y" íå ìîæåò áûòü ìåíüøå 220 è áîëüøå 340. "Ó"=300.');
  258. end;
  259. if y2>340 then
  260. begin
  261. y2:=300;
  262. showmessage('"Y" íå ìîæåò áûòü ìåíüøå 220 è áîëüøå 340. "Ó"=300.');
  263. end;
  264. end;
  265.  
  266. procedure TForm1.Timer2Timer(Sender: TObject);
  267. begin
  268. if z=2 then
  269. begin
  270. if l<775 then
  271. l:=l+1;
  272. if l1<781 then
  273. l1:=l1+1;
  274. if l2<781 then
  275. l2:=l2+1;
  276. if a3<775 then
  277. a3:=a3+1;
  278. if x2<779 then
  279. x2:=x2+1;
  280. if l=775 then
  281. y2:=y2+1;
  282. if y2=450 then
  283. timer2.Enabled:=false;
  284. end;
  285. end;
  286.  
  287. procedure TForm1.Timer3Timer(Sender: TObject);
  288. begin
  289. if x>=x2-10 then
  290. begin
  291. if ugl<90 then
  292. ugl:=ugl+1;
  293. if ugl2<135 then
  294. ugl2:=ugl2+1;
  295. if ugl3>45 then
  296. ugl3:=ugl3-1;
  297. end;
  298. end;
  299.  
  300. procedure TForm1.Timer4Timer(Sender: TObject);
  301. begin
  302. if (ugl=90) and (k>=y2+5) then
  303. begin
  304. k:=k-1;
  305. k1:=k1-1;
  306. k2:=k2-1;
  307. end;
  308. if k=y2+5 then
  309. begin
  310. timer4.Enabled:=false;
  311. timer5.Enabled:=true;
  312. end;
  313. end;
  314.  
  315. procedure TForm1.Timer5Timer(Sender: TObject);
  316. begin
  317. if k<=b2-33 then
  318. begin
  319. y2:=k-5;
  320. k:=k+1;
  321. k1:=k1+1;
  322. k2:=k2+1;
  323. end;
  324. if (k=b2-33) and (ugl=90) then
  325. z:=1;
  326. end;
  327.  
  328. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement