07/02/07 15:55
Maury91
Dipende, se vuoi vedere due sfere o ti accontenti di 2 cerchi.
Perchè il vecchio pascal che io sappia non ha liberie per il 3d ma solo per il 2d.
Potresti usare la liberia Graph.
fai cosi, negli uses aggiungi "graph".
alle variabili aggiungi : dr,md : integer;
poi quando vuoi che parta la grafica inserisci nel programma :
dr := detect;
initgraph(dr,md,'');
per disegnare un cerchio puoi usare :
circle(x,y,raggio);
P.S. :
Vedi di mettere i driver nella stessa directory che stai usando. (I file *.bgi)
Perchè il vecchio pascal che io sappia non ha liberie per il 3d ma solo per il 2d.
Potresti usare la liberia Graph.
fai cosi, negli uses aggiungi "graph".
alle variabili aggiungi : dr,md : integer;
poi quando vuoi che parta la grafica inserisci nel programma :
dr := detect;
initgraph(dr,md,'');
per disegnare un cerchio puoi usare :
circle(x,y,raggio);
P.S. :
Vedi di mettere i driver nella stessa directory che stai usando. (I file *.bgi)
aaa
07/02/07 17:26
Il Totem
Guarda questo programma, sulla grafica: fa muovere una palla in molti modi, tra cui rimbalzare.
program palla; uses crt,graph,giobe; var Gd,Gm:integer; I,X,Y,x1,y1,x2,y2:integer; R1,R2,L1,L2,R3,L3,R4,L4:integer; R5,R6,R7,R8,L5,L6,L7,L8:integer; procedure giu(G:integer); begin repeat SetColor(0); Circle(X,Y,30); Y:=Y+1; SetColor(3); Circle(X,Y,30); delay(800); until Y=G; end; procedure su(G:integer); begin repeat SetColor(0); Circle(X,Y,30); Y:=Y-1; SetColor(3); Circle(X,Y,30); delay(800); until Y=G; end; begin clrscr; VIAcur; gotoxy(60,10); write('Premere invio per iniziare'); InitGraph(Gd,Gm,''); if GraphResult <> grOk then Halt(1); SetColor(3); X:=200; Y:=100; Line(100,331,300,331); Circle(X,Y,30); delay(100); Line(400,100,600,100); Line(400,300,600,300); Line(400,100,400,300); Line(600,100,600,300); readln; giu(300); su(100); I:=100; repeat (*Fase 1*) I:=I+20; giu(300); su(I); until (I>=280) or (keypressed); giu(300); (*Fase 2*) su(200); repeat SetColor(0); Circle(X,Y,30); X:=X-1; SetColor(3); Circle(X,Y,30); delay(800); until X=150; x1:=100; x2:=300; y1:=331; y2:=331; repeat SetColor(0); Line(x1,y1,x2,y2); x1:=x1+1; x2:=x2+2; SetColor(3); Line(x1,y1,x2,y2); Delay(800); until x2=400; repeat SetColor(0); Line(x1,y1,x2,y2); y1:=y1-1; y2:=y2-1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until y2=300; repeat SetColor(0); Line(x1,y1,x2,y2); y1:=y1-1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until y1=231; x1:=400; x2:=400; y1:=200; y2:=300; repeat SetColor(0); Line(x1,y1,x2,y2); x2:=x2-2; y2:=y2-1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until x2=200; repeat SetColor(0); Line(x1,y1,x2,y2); y2:=y2-1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until y2=131; repeat SetColor(0); Circle(X,Y,30); X:=X+4; Y:=Y+1; SetColor(3); Circle(X,Y,30); delay(1100); until Y=270; Y:=269; X:=400+29; x1:=150; x2:=400; y1:=231; y2:=300; repeat SetColor(0); Line(x1,y1,x2,y2); y1:=y1+1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until y1=300; repeat PutPixel(x1,y1,0); x1:=x1+1; PutPixel(x1,y1,0); delay(800); until x1=400; x1:=400; x2:=200; y1:=200; y2:=131; repeat SetColor(0); Line(x1,y1,x2,y2); y2:=y2+1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until y2=300; repeat SetColor(0); Line(x1,y1,x2,y2); x2:=x2+1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until x2=400; I:=0; (*Fase 3*) repeat I:=I+1; repeat SetColor(0); Circle(X,Y,30); X:=X+1; SetColor(3); Circle(X,Y,30); delay(800); until X=600-31; Line(400,100,400,300); repeat SetColor(0); Circle(X,Y,30); Y:=Y-1; SetColor(3); Circle(X,Y,30); delay(800); until Y=131; repeat SetColor(0); Circle(X,Y,30); X:=X-1; SetColor(3); Circle(X,Y,30); delay(800); until X=431; repeat SetColor(0); Circle(X,Y,30); Y:=Y+1; SetColor(3); Circle(X,Y,30); delay(800); until Y=300-31; until I=2; x1:=400; x2:=600; y1:=100; y2:=100; repeat SetColor(0); Line(x1,y1,x2,y2); y1:=y1-1; y2:=y2-1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until y1=1; repeat x1:=x1-1; x2:=x2+1; if x1>0 then PutPixel(x1,y1,3); if x2<GetMaxX then PutPixel(x2,y2,3); delay(800); until x1=1; x1:=400; x2:=600; y1:=300; y2:=300; repeat SetColor(0); Line(x1,y1,x2,y2); y1:=y1+1; y2:=y2+1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until y1=GetMaxY; repeat x1:=x1-1; x2:=x2+1; if x1>0 then PutPixel(x1,y1,3); if x2<GetMaxX then PutPixel(x2,y2,3); delay(800); until x1=1; x1:=400; x2:=400; y1:=100; y2:=300; repeat SetColor(0); Line(x1,y1,x2,y2); x1:=x1-1; x2:=x2-1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until x1=1; x1:=1; repeat y1:=y1-1; y2:=y2+1; if y1>0 then PutPixel(x1,y1,3); if y2<GetMaxY then PutPixel(x2,y2,3); delay(800); until y2=GetMaxY; x1:=600; x2:=600; y1:=100; y2:=300; repeat SetColor(0); Line(x1,y1,x2,y2); x1:=x1+1; x2:=x2+1; SetColor(3); Line(x1,y1,x2,y2); delay(800); until x1=GetMaxX; repeat y1:=y1-1; y2:=y2+1; if y1>0 then PutPixel(x1,y1,3); if y2<GetMaxY then PutPixel(x2,y2,3); delay(800); until y2=GetMaxY; repeat SetColor(0); Circle(X,Y,30); X:=X-1; SetColor(3); Circle(X,Y,30); delay(800); until X=GetMaxX div 2; repeat SetColor(0); Circle(X,Y,30); Y:=Y-1; SetColor(3); Circle(X,Y,30); delay(800); until Y=GetMaxY div 2; R1:=0; L1:=1; repeat R1:=R1+1; PutPixel(R1,L1,0); delay(800); until R1=GetMaxX; repeat L1:=L1+1; PutPixel(R1,L1,0); delay(800); until L1=GetMaxY; repeat R1:=R1-1; PutPixel(R1,L1,0); delay(800); until R1=1; repeat L1:=L1-1; PutPixel(R1,L1,0); delay(800); until L1=1; R1:=X; L1:=Y; R2:=X; L2:=Y; (*Fase 4*) repeat SetColor(0); Circle(R1,L1,30); Circle(R2,L2,30); R1:=R1+1; R2:=R2-1; SetColor(3); Circle(R1,L1,30); Circle(R2,L2,30); delay(800); until R1=GetMaxX-31; repeat SetColor(0); Circle(R1,L1,30); CIrcle(R2,L2,30); L1:=L1-1; L2:=L2+1; SetColor(3); Circle(R1,L1,30); Circle(R2,L2,30); delay(800); until L2=GetMaxY-31; repeat SetColor(0); Circle(R1,L1,30); CIrcle(R2,L2,30); R1:=R1-1; R2:=R2+1; SetColor(3); Circle(R1,L1,30); Circle(R2,L2,30); delay(800); until R2=GetMaxX div 2; PutPixel(1,L2,3); repeat SetColor(0); Circle(R1,L1,30); CIrcle(R2,L2,30); L1:=L1+1; L2:=L2-1; SetColor(3); Circle(R1,L1,30); Circle(R2,L2,30); PutPixel(R1,GetMaxY,3); PutPixel(R2,GetMaxY,3); delay(800); until L2=GetMaxY div 2; X:=GetMaxX div 2; Y:=GetMaxY div 2; R1:=X; R2:=X; R3:=X; R4:=X; L1:=Y; L2:=Y; L3:=Y; L4:=Y; (*Fase 5*) repeat setColor(0); Circle(R1,L1,30); Circle(R2,L2,30); Circle(R3,L3,30); Circle(R4,L4,30); if L1>1 then begin L1:=L1-1; L3:=L3+1; end else begin L1:=1; L3:=1; end; R2:=R2+1; R4:=R4-1; SetColor(3); Circle(R1,L1,30); Circle(R2,L2,30); Circle(R3,L3,30); Circle(R4,L4,30); delay(800); until R2=GetMaxX-31; SetColor(0); Y:=0; X:=1; (*Fase Finale*) repeat Y:=Y+1; Line(X,Y,GetMaxX,Y); until Y=GetMaxY; SetColor(3); x1:=1; y1:=GetMaxY; x2:=1; y2:=1; Line(x1,y1,x2,y2); repeat x2:=x2+1; Line(x1,y1,x2,y2); delay(800); until x2=GetMaxX; repeat y2:=y2+1; Line(x1,y1,x2,y2); delay(800); until y2=GetMaxY; CloseGraph; RestoreCrtMode; write('Fine.'); readln end.
aaa