program Moving_Circles; uses Graph, Crt; const c1=green; c2=red; s1='Moving circles'; s2='studentka of 11 group'; s3='Mariska'; D=25000; var gd,gm,i,m,m1,n,n1,r,x,x1,y,y1: integer; a,a1: real; q: char; flag,f: boolean; s:string; procedure Change(g1,g2:integer;var n:integer;a:real); begin if g1>=g2 then begin sound(random(100)+880);randomize; n:=-n; a:=3.14*(random(90))/180;end; end; procedure Change2(x,x1:integer;var n,m,n1,m1:integer); begin if x>=x1 then begin n:=abs(n);m:=-abs(m1);n1:=-abs(n1);m1:=abs(m);end; end; procedure Exit(x,y,r:integer;var flag:boolean); begin if (x-r<50) or (x+r>570) or (y-r<50) or (y+r>450) then begin flag:=true; SetColor(red); OutTextXY(170,190,'Sorry, fatal programm error! Press any key'); ReadKey end; end; procedure P_Speed(var m:integer); begin if m<20 then m:=m+round(m/abs(m)); end; procedure M_Speed(var m:integer); begin if m>1 then m:=m-round(m/abs(m)); end; procedure Paint(x,y,r,c:integer); begin SetFillStyle(1,c); SetColor(c); Circle(x,y,r); FloodFill(x,y,c); end; procedure MENU(x,y,x1,y1:integer;s:string;c:word); begin SetColor(c); RecTangle(x,y,x1,y1); SetColor(red); OutTextXY(round(x+(x1-x-TextWidth(s))/2),round(y+(y1-y)/2),s); end; procedure _case_(var x,y,x1,y1:integer;var q:char;var r:integer); var s:string; begin case q of '1':begin Menu(x,y,x1,y1,s,white); x:=200; y:=150; x1:=300; y1:=200; s:='R=35'; Menu(x,y,x1,y1,s,cyan); r:=35; end; '2':begin Menu(x,y,x1,y1,s,white); x:=350; y:=150; x1:=450; y1:=200; s:='R=45'; Menu(x,y,x1,y1,s,cyan); r:=45; end; '3':begin Menu(x,y,x1,y1,s,white); x:=200; y:=300; x1:=300; y1:=350; s:='R=55'; Menu(x,y,x1,y1,s,cyan); r:=55; end; '4':begin Menu(x,y,x1,y1,s,white); x:=350; y:=300; x1:=450; y1:=350; s:='R=65'; Menu(x,y,x1,y1,s,cyan); r:=35; end; end; end; procedure music(var x,y,x1,y1,r:integer); var flag:boolean; q:char; begin {+++++++++++++Music(Lumen - Sid & Nancy)+++++++++++++} flag:=false; while not flag do begin if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; {+++++++++++++Em+++++++++++++} sound(330); delay(d); nosound; sound(330); delay(d); nosound; sound(494); delay(d); nosound; sound(330); delay(d); nosound; if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; sound(523); delay(d); nosound; sound(330); delay(d); nosound; sound(494); delay(d); nosound; sound(523); delay(d); nosound; if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; {+++++++++++++D+++++++++++++} sound(294); delay(d); nosound; sound(294); delay(d); nosound; sound(494); delay(d); nosound; if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; sound(294); delay(d); nosound; sound(523); delay(d); nosound; sound(294); delay(d); nosound; sound(494); delay(d); nosound; sound(523); delay(d); nosound; if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; {+++++++++++++C+++++++++++++} sound(262); delay(d); nosound; sound(262); delay(d); nosound; sound(494); delay(d); nosound; sound(262); delay(d); nosound; sound(523); delay(d); nosound; if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; sound(262); delay(d); nosound; sound(494); delay(d); nosound; sound(523); delay(d); nosound; if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; {+++++++++++++D+++++++++++++} sound(294); delay(d); nosound; sound(294); delay(d); nosound; sound(523); delay(d); nosound; sound(494); delay(d); nosound; if KeyPressed then begin q:=readkey; _case_(x,y,x1,y1,q,r); if q=#13 then break; end; {+++++++++++++D#+++++++++++++} sound(312); delay(d); nosound; sound(312); delay(d); nosound; sound(523); delay(d); nosound; sound(494); delay(d); nosound; end; end; begin begin Gd:=Detect; InitGraph(Gd, Gm, ''); If GraphResult <> grOk Then Halt(1); end; x:=200; y:=150; x1:=300; y1:=200; Menu(x,y,x1,y1,'R=35',cyan); r:=35; Menu(x+150,y,x1+150,y1,'R=45',white); Menu(x,y+150,x1,y1+150,'R=55',white); Menu(x+150,y+150,x1+150,y1+150,'R=65',white); OutTextXY(x-10,y-10,'1:'); OutTextXY(x+140,y-10,'2:'); OutTextXY(x-10,y+140,'3:'); OutTextXY(x+140,y+140,'4:'); SetColor(yellow); RecTangle(x-30,y-30,x1+170,y1+170); SetColor(green); OutTextXY(320-(TextWidth(s1) div 2),70,s1); OutTextXY(320-(TextWidth(s2) div 2),80,s2); OutTextXY(320-(TextWidth(s3) div 2),90,s3); SetColor(12); OutTextXY(460-(TextWidth(s2) div 2),400,'Music:Lumen - Sid & Nancy'); OutTextXY(x-10,y-25,'Choose radius and press Enter'); Music(x,y,x1,y1,r); ClearViewPort; {+++++++++++++Seting of X & Y+++++++++++++} flag:=false; Randomize; a:=45; a1:=70; m:=1; n:=1; x1:=random(100)+220+r; y1:=random(100)+200+r; m1:=1; n1:=-1; x:=random(100)+100+r; y:=random(80)+100+r; {+++++++++++++Paint working desk+++++++++++++} SetColor(white); SetFillStyle(1,white); Rectangle(50,50,570,450); FloodFill(51,51,white); SetColor(green); Rectangle(48,48,572,452); {+++++++++++++Moving 1-st and 2-nd circles+++++++++++++} SetColor(red); OutTextXY(235,30,'Press Esc to stop'); SetColor(c1); OutTextXY(1,1,'1-st circle'); OutTextXY(1,10,'to increase: +'); OutTextXY(1,20,'to decrease: -'); SetColor(c2); OutTextXY(500,1,'2-nd circle'); OuttextXY(500,10,'to increase: UP'); OutTextXY(500,20,'to decrease: DOWN'); while not flag do begin if KeyPressed then q:=ReadKey; case q of #43: begin q:='q';P_Speed(m);P_Speed(n);end; #45: begin q:='q';M_Speed(m);M_Speed(n);end; #80: begin q:='q';M_Speed(m1);M_Speed(n1);end; #72: begin q:='q';P_Speed(m1);P_Speed(n1);end; else flag:=q=#27; end; Paint(x,y,r,c1); Paint(x1,y1,r,c2); Delay(round(d/2)); NoSound; FloodFill(51,51,white); paint(x,y,r,white); paint(x1,y1,r,white); Exit(x,y,r,flag); Exit(x1,y1,r,flag); Change(50,x-r-abs(n)-1,n,a); Change(50,y-r-abs(m)-1,m,a); Change(x+r+abs(n)+1,570,n,a); Change(y+r+abs(m)+1,450,m,a); Change(50,x1-r-abs(n1)-1,n1,a1); Change(50,y1-r-abs(m1),m1,a1); Change(x1+r+abs(n1)+1,570,n1,a1); Change(y1+r+abs(m1)+1,450,m1,a1); f:=(sqrt(sqr(x1/10-x/10)+sqr(y1/10-y/10))*10<=2*r+round(abs(n)+abs(m1))/4); if f then begin Randomize; Sound(random(100)+243); a:=3.14*(random(45)+45)/180; a1:=3.14*(random(45)+45)/180; Change2(x,x1,n,m,n1,m1); Change2(x1,x,n1,m1,n,m); end; f:=(sqrt(sqr(x1/10-x/10)+sqr(y1/10-y/10))*10<=2*r+round(abs(n)+abs(m1))/2); if f then begin x1:=round(x1+n1/2*cos(a1)); y1:=round(y1+m1/2*sin(a1)); x:=round(x+n/2*cos(a)); y:=round(y+m/2*sin(a)); end else begin x1:=round(x1+n1*cos(a1)); y1:=round(y1+m1*sin(a1)); x:=round(x+n*cos(a)); y:=round(y+m*sin(a)); end; end; NoSound; {++++++++++++++++++++++++++++++++++++++++++++++++++++++} SetColor(red); OutTextXY(200,230,'Please, press any key to exit'); ReadKey; CloseGraph; end.