Home - qdidactic.com
Didactica si proiecte didacticeBani si dezvoltarea cariereiStiinta  si proiecte tehniceIstorie si biografiiSanatate si medicinaDezvoltare personala
referate stiintaSa fii al doilea inseamna sa fii primul care pierde - Ayrton Senna





Aeronautica Comunicatii Drept Informatica Nutritie Sociologie
Tehnica mecanica

C


Qdidactic » stiinta & tehnica » informatica » c
Program Tenis in C



Program Tenis in C



Program Tenis;


Uses Crt;

Const viteza=1500;

Type Ecran=Record

car:char;

atrib:byte;

End;

Var

scr:array[1..25,1..80] of Ecran absolute $b800:$0;

x,y,x0,y0:byte;

i,d,s:integer;

u:real;

ok:boolean;

tasta:char;

yP1:array[1..5]of byte;



yP2:array[1..5]of byte;

uP:array[1..5]of real;


Procedure Paleta1(tip:char);

Begin                         

for i:=1 to 5 do

scr[yP1[i],76].car:=tip;

end;

Procedure Paleta2(tip:char);

Begin                         

for i:=1 to 5 do

scr[yP2[i],5].car:=tip;

End;

Procedure Mutapaleta1;

Begin

Paleta1(' ');

if (tasta=#80) and (yP1[i]<24) then

for i:=1 to 5 do Inc(yP1[i]);

if (tasta=#72) and (yP1[i]>6) then

for i:=1 to 5 do Dec(yP1[i]);

End;

Procedure Mutapaleta2;

Begin

Paleta2(' ');

if (tasta=#122) and (yP2[i]<24) then

for i:=1 to 5 do Inc(yP2[i]);

if (tasta=#119) and (yP2[i]>6) then

for i:=1 to 5 do Dec(yP2[i]);

End;

procedure cantec;

begin sound(400);delay(800);

sound(500);delay(800);

sound(600);delay(800);

sound(650);delay(800);

sound(600);delay(800);

sound(700);delay(800);

sound(650);delay(1000);

end;

Begin

Clrscr;

d:=0;s:=0;



clrscr;

For x:=1 to 80 do begin

scr[1,x].car :=#219;

scr[25,x].car:=#219;

end;

For y:=2 to 9 do begin

scr[y,1].car :=#219;

scr[y,80].car:=#219;

end;

For y:=17 to 24 do begin

scr[y,1].car :=#219;

scr[y,80].car:=#219;

end;

x0:=40;

y0:=13;

u:=20*PI/180;

x:=x0;

y:=y0;

for i:=1 to 5 do begin

yP1[i]:=10+i;

yP2[i]:=10+i;

uP[i]:=(i/3*PI-PI)/15;

end;

tasta:=' ';

repeat

if ((u>=0) and (u<PI/2) or (u > 3*PI/2) and (u<2*PI)) then inc(x)

else dec(x);

y:=y0+Trunc(Abs(x-x0) * Sin(u)/Cos(u));

if scr[y,x].car<>' ' then begin

if (y=1)or(y=25) then begin

u:=2*PI-u;x0:=x;

if y=1 then y0:=2 else y0:=24;

end;

if (x=1)or(x=80) then begin

u:=PI+u;if u>2*Pi then u:=u-2*PI;

y0:=y;

if x=1 then x0:=2 else x0:=79;

end;

if x=76 then begin

for i:=1 to 5 do

if y=yP1[i] then begin

sound(1000);

u:=PI+u+uP[i];

if u>2*Pi then u:=u-2*PI;

x0:=x;y0:=y;

end;

nosound;

end;

if x=5 then begin

for i:=1 to 5 do

if y=yP2[i] then begin

sound(600);

u:=PI+u+uP[i];

if u>2*Pi then u:=u-2*PI;

x0:=x;y0:=y;

end;

nosound;

end;

end

else if not (((x=1)or(x=80)) and((y<17)and(y>8))) then

begin

scr[y,x].car:='0';

i:=1;

ok:=false;

repeat

ok:=keypressed;

inc(i);

until (i=viteza)or ok;

if ok then begin

tasta:=readkey;

if tasta = #0 then tasta:=readkey;

mutapaleta1;

mutapaleta2;

end;

Paleta1(#219);

Paleta2(#219);

scr[y,x].car:=' ';

scr[y,x].car:=' ';

end

else begin

sound(800);

if (x>=80)and(y>9)and(y<17) then d:=d+1;

if (x<=1)and(y>9)and(y<17) then s:=s+1;

textcolor(2);

textbackground(7);

gotoxy(39,2);

write('SCOR');

gotoxy(38,3);

write(' ',d,' : ',s);

if (d=5)or(s=5) then begin

gotoxy(35,10);

write(' G A M E O V E R ');

cantec; nosound;

halt;

end;

delay(1500);

paleta1(' ');

paleta2(' ');

x0:=40;

y0:=13;

u:=20*PI/180;

x:=x0;

y:=y0;

for i:=1 to 5 do begin

yP1[i]:=10+i;

yP2[i]:=10+i;

uP[i]:=(i/3*PI-PI)/5;

end;

tasta:=' ';

nosound;

end;

until tasta=#27;

End.




Contact |- ia legatura cu noi -| contact
Adauga document |- pune-ti documente online -| adauga-document
Termeni & conditii de utilizare |- politica de cookies si de confidentialitate -| termeni
Copyright © |- 2024 - Toate drepturile rezervate -| copyright