Name: Title:

 Name:
ONLINE COMPILERS
LIBRARY
MANUAL PAGES & DOCS
CONTACT

User Submitted Source Code!

Description:
aaac
Language: PASCAL
Code:
Program seminarna_praca;
uses crt,graph;
var gd,gm:smallint;
c,b2,a2:real;
smer: char;
a,b,w,x,d,f,g,h,q,p,x1,x2,x3,y1,y,y3,u,z,k,j,l:integer;
const VLAVO=#75;VPRAVO=#77;ENTER=#13;
PROCEDURE lava_stena;                         {1.procedura-odraz od lavej steny}
begin
repeat
g:=1;
setcolor(black);
line(x1,580,x2,580);
setcolor(white);
case smer of
VLAVO:
begin
x1:=x1-10;
x2:=x2-10;
end;
VPRAVO:
begin
x1:=x1+10;
x2:=x2+10;
end;
ENTER:
g:=500;
end;
line(x1,580,x2,580);
until  g=500;
if y3=123 then
begin
setcolor(black);
line(575,120,675,120);
if u=10 then
begin
a2:=580-w;
end
else
begin
a2:=460-a2;
end;
b2:=(b*a2)/a;
x:=253;
x3:=253;
y3:=557;
d:=round(b2);
z:=2;
u:=2;
while (y<=577) and (x<=997) do
begin
d:=d-1;;
c:=(a2*(d-3))/b2;
y:=580-round(c);
x:=x+1;
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
delay(1);
setcolor(black);
circle(x,y,3);
line(0,580,249,580);
line(0,120,249,120);
line((x-50)-l,120,(x+50)-l,120);
if x>997 then
begin
w:=y;
u:=10;
y3:=123;
end;
end;
end
else
begin
if u=10 then
begin
a2:=w-120;
end
else
begin
a2:=460-a2;
end;
b2:=(b*a2)/a;
d:=round(b2);
x3:=253;
y3:=123;
z:=2;
u:=2;
while (y>=123) and (x<=997) do
begin
d:=d-1;
c:=(a2*d)/b2;
x:=round(250+b2-d);
y:=123+round(c);
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
delay(1);
setcolor(black);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
if x>997 then
begin
w:=y;
u:=10;
y3:=577;
end;
end;
end;
end;
PROCEDURE prava_stena;                       {2.procedura-odraz od pravej steny}
begin
repeat
g:=1;
setcolor(black);
line(x1,580,x2,580);
setcolor(white);
case smer of
VLAVO:
begin
x1:=x1-10;
x2:=x2-10;
end;
VPRAVO:
begin
x1:=x1+10;
x2:=x2+10;
end;
ENTER:
g:=500;
end;
setcolor(white);
line(x1,580,x2,580);
until  g=500;
if y3=123 then
begin
if u=10 then
begin
a2:=580-w;
end
else
begin
a2:=460-a2;
end;
b2:=(b*a2)/a;
d:=round(b2);
x3:=997;
y3:=577;
z:=2;
u:=2;
while (y<577) and (x>=253) do
begin
d:=d-1;
c:=(a2*d)/b2;
x:=round(1000-b2)+d;
y:=580-round(c);
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
setcolor(black);
delay(1);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
if x<253 then
begin
w:=y;
u:=10;
y3:=123;
end;
end;
end
else
begin
if u=10 then
begin
a2:=w-120;
end
else
begin
a2:=460-a2;
end;
b2:=(b*a2)/a;
d:=round(b2);
x3:=997;
y3:=123;
z:=2;
u:=2;
while (y>123) and (x>=253) do
begin
d:=d-1;
c:=(a2*d)/b2;
x:=1000-round(b2-d);
y:=120+round(c);
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
setcolor(black);
delay(1);     circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
setcolor(white);
if x<253 then
begin
w:=y;
u:=10;
y3:=577;
end;
end;
end;
end;
PROCEDURE dolna_stena;                       {3.procedura-odraz od dolnej steny}
begin
if (x<x1) or (x>x2) then
begin
h:=1000;
j:=j+1;
write('Netrafil si sa');
end;
if x3=253 then
begin
if z=10 then
begin
b2:=1000-k;
x:=k;
end
else
begin
x:=250+round(b2);
b2:=750-b2;
end;
a2:=(a*b2)/b;
d:=0;
y3:=577;
z:=2;
u:=2;
x3:=997;
while (x<=997) and (y>=123) do
begin
d:=d+1;
c:=(a2*d)/b2;
f:=round(c);
y:=580-f;
x:=x+1;
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
setcolor(black);
line(1050,120,1300,120);
delay(1);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
if y<123 then
begin
z:=10;
x3:=253;
k:=x;
end;
end;
end
else
begin
if z=10 then
begin
b2:=k-250;
end
else
begin
b2:=750-b2;
end;
a2:=(a*b2)/b;
d:=0;
y3:=577;
u:=2;
z:=2;
x3:=253;
while (x>=253) and (y>=123) do
begin
d:=d+1;
c:=(a2*d)/b2;
x:=round(250+b2-d);
y:=round(580-c);
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
setcolor(black);
line(1050,120,1300,120);
delay(1);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
if y<123 then
begin
k:=x;
z:=10;
x3:=997;
y3:=123;
end;
end;
end;
end;
PROCEDURE horna_stena;                       {4.procedura-odraz od hornej steny}
begin
if (x<((x-50)-l)) or (x>((x-50)+l)) then
begin
if h=0 then
begin
h:=1000;
p:=p+1;
write('Pocitac sa netrafil');
end;
end;
if (x3=997) then
begin
setcolor(black);
line(575,120,675,120);
if z=10 then
begin
b2:=k-250;
end
else
begin
b2:=750-b2;
end;
a2:=(a*b2)/b;
d:=0;
y3:=123;
x3:=253;
x:=round(250+b2);
u:=2;
z:=2;
while (x>=253) and (y<=577) do
begin
d:=d+1;
c:=(a2*d)/b2;
y:=120+round(c);
x:=x-1;
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
delay(1);
setcolor(black);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
setcolor(white);
if y<577 then
z:=10;
k:=x;
x3:=997;
end;
end
else
begin
if z=10 then
begin
b2:=1000-k;
end
else
begin
b2:=750-b2;
end;
a2:=(a*b2)/b;
d:=0;
y3:=123;
x:=round(1000-b2);
x3:=253;
u:=2;
z:=2;
while (x<=997) and (y<=577) do
begin
d:=d+1;
c:=(a2*d)/b2;
y:=120+round(c);
x:=x+1;
setcolor(white);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
setcolor(black);
delay(1);
circle(x,y,3);
line((x-50)-l,120,(x+50)-l,120);
if y>577 then
z:=10;
k:=x;
x3:=253;
end;
end;
end;                                                           {Koniec procedur}
begin
detectgraph(gd,gm);
initgraph(gd,gm,'');
randomize;
x:=625;
q:=0;
d:=0;
x1:=575;
x2:=675;
j:=0;
p:=0;
l:=50;
line(575,580,675,580);
repeat
y1:=random(250);
y1:=y1+270;
x:=625;
d:=0;
b:=375;
b2:=b;
a:=y1-120;
a2:=a;
y:=123;
y3:=123;
x3:=253;
w:=0;
k:=0;
u:=2;
z:=2;
setcolor(blue);
settextstyle(0,0,10);
outtextxy(270,10,'ping pong');
settextstyle(0,0,2);
setcolor(red);
rectangle(250,100,1000,600);
setcolor(white);
line(575,120,675,120);
circle(625,123,3);
while x>253  do
begin
setcolor(black);
circle(625,123,3);
circle(x,y,3);
a:=y1-120;
b:=375;
d:=d+1;
c:=(a*d)/b;
y:=round(c+123);
x:=x-1;
setcolor(white);
line((x-50)-l,120,(x+50)-l,120);
circle(x,y,3);
delay(1);
setcolor(black);
line((x-50)-l,120,(x+50)-l,120);
line(625,120,725,120);
end;
REPEAT
h:=0;
if q=0 then
l:=-90;
if q=1 then
l:=-70;
if q=2 then
l:=-80;
setcolor(red);
rectangle(250,100,1000,600);
IF x<=253 THEN
begin
lava_stena;
end;
IF y>=577 THEN
begin
dolna_stena;
end;
IF y<=123 THEN
begin
horna_stena;
end;
IF x>=997 THEN
begin
prava_stena
end;
UNTIL h=1000;
clrscr;
writeln('POCITAC:HRAC=',j,':',p);
q:=q+1;
until q=3;
clrscr;
writeln('VYSLEDOK=POCITAC:HRAC=',j,':',p);
if j>p then
if j=3 then
outtextxy(450,800,'Pocitac vyhral pomerom 3:0')
else
outtextxy(450,800,'Pocitac vyhral pomerom 2:1');
if j<p then
if j=0 then
outtextxy(450,800,'Hrac vyhral pomerom 0:3')
else
outtextxy(450,800,'Hrac vyhral pomerom 1:2');