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 Biliard; { demonstrativ pentru folosirea modului grafic }



Program Biliard; { demonstrativ pentru folosirea modului grafic }


Program Biliard

uses Graph,Crt;

Const nr_obiecte=10;

raza=25;

pasx=3;pasy=2;

viteza=10;

var

grDriver,grMode,ErrCode: Integer;

i,xMax,yMax,xtmp,ytmp:word;

x,y:Array[1..nr_obiecte] of word;

sensx,sensy:Array[1..nr_obiecte] of shortint;


Procedure Deseneaza(x,y,color:word);

Const bucati=12;

Var x1,y1,unghi,Xasp,Yasp:word;

Begin

SetWriteMode(XORPut);SetColor(color);

GetAspectRatio(Xasp, Yasp);

unghi:=0;

x1:=x+Trunc(raza*cos(unghi*2*PI/bucati));

y1:=y+Trunc(raza*sin(unghi*2*PI/bucati)*Xasp/Yasp);

For unghi:=1 to bucati do begin

xtmp:=x+Trunc(raza*cos(unghi*2*PI/bucati));

ytmp:=y+Trunc(raza*sin(unghi*2*PI/bucati)*Xasp/Yasp);

Line(x1,y1,xtmp,ytmp);Line(x,y,x1,y1);

x1:=xtmp;y1:=ytmp;

end;

End;


begin



grDriver := Detect;

InitGraph(grDriver, grMode,'');

ErrCode := GraphResult;

if ErrCode = grOk then

begin

xMax:=GetMaxX;yMax:=GetMaxY;

Rectangle(0,0,xMax,yMax);

Randomize;

For i:=1 to nr_obiecte do begin

x[i]:=raza+Random(xMax-2*raza);y[i]:=raza+Random(yMax-2*raza);

sensx[i]:=-1+(i mod 2)*2;sensy[i]:=-sensx[i];

Deseneaza(x[i],y[i],i);

end;

Repeat

For i:=1 to nr_obiecte do begin

Deseneaza(x[i],y[i],i);

xtmp:=x[i]+pasx*sensx[i];ytmp:=y[i]+pasy*sensy[i];

If (xtmp>raza) and (xtmp<xMax-raza) then x[i]:=xtmp

else sensx[i]:=-sensx[i];

If (ytmp>raza) and (ytmp<yMax-raza) then y[i]:=ytmp

else sensy[i]:=-sensy[i];

Deseneaza(x[i],y[i],i);

Delay(100-10*viteza);

end;

Until KeyPressed;

Readln;

CloseGraph;

end

else

Writeln('Graphics error:', GraphErrorMsg(ErrCode));

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