من چیز خاصی تعریف نکردم.همون کامپایلر Turbo Pascal 7.0 dos هستش.کامپایلرت چیه؟
program p1;
uses crt,graph;
const adamak=chr(2); adamak1=chr(1);ziad=chr(43);kam=chr(45);setare=chr(42);space=chr(32);
var grdriver,k,p,m,h,o,j,grmode,i,errcode:integer;chkey:char;
begin
for i:=0 to 5 do
writeln ('');
writeln (' @ @ ');
writeln (' @@@ (+) for high race & (-) for low race @@@');
writeln (' @ @ ');
for i:=0 to 5 do
writeln ('');
writeln (' @ @ ');
writeln (' @@@ press (space) for exit & press (*) for buzz @@@ ');
writeln (' @ @ ');
for i:=0 to 10 do
writeln ('');
writeln (' @@@@ @@@@ ');
writeln (' @@@@@@ @@@@@@ ');
writeln (' @@@@@@ @@@@@@ ');
writeln (' @@@@ @@@@ ');
writeln (' ');
writeln (' ');
writeln (' ');
writeln (' @ @ ');
writeln (' @@ @@ ');
writeln (' @@@ @@@ ');
writeln (' @@@@@ @@@@@ ');
writeln (' @@@@@@@@@@@@@ ');
delay(5000);
grdriver:=detect;
initgraph(grdriver,grmode,'c:\tp\bgi');
errcode:=graphresult;
if errcode<>grok then
writeln('graph error',errcode)
else
begin
setbkcolor(15);
setcolor(6);
line(-1,250,155,250);
line(465,250,800,250);
setcolor(1);
for i:=8 to 20 do
begin
circle(220,300,i);
circle(400,300,i);
end;
line(240,300,380,300);
line(200,300,150,300);
line(420,300,470,300);
line(470,300,470,275);
line(470,275,150,275);
line(465,150,155,150);
line(155,150,155,275);
line(150,300,150,275);
line(150,295,145,295);
line(145,295,145,290);
line(145,290,150,290);
line(465,150,465,275);
rectangle(360,160,420,270);
rectangle(389,160,391,270);
setcolor(3);
line(152,160,152,168);
arc(465,265,270,90,5);
arc(155,160,90,180,3);
arc(155,168,180,270,3);
setcolor(14);
for i:=0 to 20 do
circle(500,50,i);
setcolor(9);
rectangle(165,160,225,220);
rectangle(230,160,290,220);
rectangle(295,160,355,220);
settextstyle(10,0,1);
outtextxy(200,225,'seirosafar');
setfillstyle(9,11);
bar3d(365,165,385,220,0,topon);
bar3d(395,165,415,220,0,topon);
bar3d(430,165,465,255,0,topon);
setcolor(6);
setfillstyle(6,10);
bar3d(-1,380,800,600,1,topon);
o:=100;
for j:=0 to 5 do
for i:=0 to 360 do
begin
if keypressed then
begin
chkey:=readkey;
if ((chkey=ziad)and(o>0)) then
o:=o-10;
if (chkey=kam)and(o<200) then
o:=o+10;
if chkey=setare then
begin
for h:=0 to 20 do
begin
sound(704);
setcolor(14);
arc(470,265,270,90,5);
arc(475,265,270,90,5);
arc(467,265,270,90,2);
arc(467,265,270,90,1);
delay(5);
setcolor(15);
arc(470,265,270,90,5);
arc(475,265,270,90,5);
arc(467,265,270,90,2);
arc(467,265,270,90,1);
nosound;
end;
end;
if chkey=space then
halt(1);
end;
setcolor(14);
circle(500,50,round(i/36)+22);
setcolor(15);
setfillstyle(9,15);
bar3d(160-i+1,320,200-i+1,330,0,topon);
bar3d(420-i+1,320,460-i+1,330,0,topon);
bar3d(240-i+1,320,380-i+1,330,0,topon);
bar3d(-20-i+1,320,120-i+1,330,0,topon);
bar3d(500-i+1,320,640-i+1,330,0,topon);
bar3d(680-i+1,320,720-i+1,330,0,topon);
bar3d(760-i+1,320,900-i+1,330,0,topon);
line(147,292,90,200);
setcolor(15);
arc(220,300,0-i,100-i,13);
arc(400,300,0-i,100-i,13);
setcolor(7);
setfillstyle(9,7);
bar3d(160-i,320,200-i,330,0,topon);
bar3d(420-i,320,460-i,330,0,topon);
bar3d(240-i,320,380-i,330,0,topon);
bar3d(-20-i,320,120-i,330,0,topon);
bar3d(500-i,320,640-i,330,0,topon);
bar3d(680-i,320,720-i,330,0,topon);
bar3d(760-i,320,900-i,330,0,topon);
p:=(round(i/60));
ellipse(140-(4*p)-6,292,0,360,3,p+2);
ellipse(140-(4*p)-2,292,0,360,3,p+1);
ellipse(140-(4*p)+2,292,0,360,3,p);
setcolor(1);
arc(220,300,0-i,100-i,13);
arc(400,300,0-i,100-i,13);
delay(0);
setcolor(6);
k:=round(i/30)-3;
setfillstyle(k,10);
bar3d(-1,380,800,600,1,topon);
setcolor(15);
circle(500,50,(round(i/36)+22));
SETTEXTSTYLE(0,0,2);
outtextxy(175+m,195,adamak);
outtextxy(195+m,195,adamak1);
arc(182+m,219,0,180,10);
arc(202+m,219,0,180,10);
setcolor(15);
outtextxy(240+m,195,adamak);
outtextxy(260+m,195,adamak1);
arc(247+m,219,0,180,10);
arc(267+m,219,0,180,10);
setcolor(15);
ellipse(140-(4*p)-6,292,0,360,3,p+2);
ellipse(140-(4*p)-2,292,0,360,3,p+1);
ellipse(140-(4*p)+2,292,0,360,3,p);
outtextxy(305+m,195,adamak);
outtextxy(325+m,195,adamak1);
arc(312+m,219,0,180,10);
arc(332+m,219,0,180,10);
setcolor(6);
m:=round(i/30);
SETTEXTSTYLE(0,0,2);
outtextxy(175+m,195,adamak);
outtextxy(195+m,195,adamak1);
arc(182+m,219,0,180,10);
arc(202+m,219,0,180,10);
setcolor(12);
outtextxy(240+m,195,adamak);
outtextxy(260+m,195,adamak1);
arc(247+m,219,0,180,10);
arc(267+m,219,0,180,10);
setcolor(10);
outtextxy(305+m,195,adamak);
outtextxy(325+m,195,adamak1);
arc(312+m,219,0,180,10);
arc(332+m,219,0,180,10);
delay(o);
end;
end;
readln;
closegraph
end.
ممنون.
من با توربو پاسکال 7 الان مقداری کار کردم.
اولین اشکال خطایی به نام division by zero بود که با پچ زیر رفع میشه. گویا در cpu های پر سرعت ایجاد میشه.
http://saalek110c.250free.com/rars/bp7patc1.zip
اگر لینک بالا مشکل داشت از سایت اصلی دانلود کنید.60 کیلو هم بیشتر نیست.
http://skhowell.com/pascalsource.htm
یک برنامه نمونه هم که البته ربطی به سئوال شما نداره را برای تست می گذارم.
از این آدرس:
http://www.partovedarya.blogfa.com/post-61.aspx
کد:program p1; uses crt,graph; const adamak=chr(2); adamak1=chr(1);ziad=chr(43);kam=chr(45);setare=chr(42);space=chr(32); var grdriver,k,p,m,h,o,j,grmode,i,errcode:integer;chkey:char; begin for i:=0 to 5 do writeln (''); writeln (' @ @ '); writeln (' @@@ (+) for high race & (-) for low race @@@'); writeln (' @ @ '); for i:=0 to 5 do writeln (''); writeln (' @ @ '); writeln (' @@@ press (space) for exit & press (*) for buzz @@@ '); writeln (' @ @ '); for i:=0 to 10 do writeln (''); writeln (' @@@@ @@@@ '); writeln (' @@@@@@ @@@@@@ '); writeln (' @@@@@@ @@@@@@ '); writeln (' @@@@ @@@@ '); writeln (' '); writeln (' '); writeln (' '); writeln (' @ @ '); writeln (' @@ @@ '); writeln (' @@@ @@@ '); writeln (' @@@@@ @@@@@ '); writeln (' @@@@@@@@@@@@@ '); delay(5000); grdriver:=detect; initgraph(grdriver,grmode,'c:\tp\bgi'); errcode:=graphresult; if errcode<>grok then writeln('graph error',errcode) else begin setbkcolor(15); setcolor(6); line(-1,250,155,250); line(465,250,800,250); setcolor(1); for i:=8 to 20 do begin circle(220,300,i); circle(400,300,i); end; line(240,300,380,300); line(200,300,150,300); line(420,300,470,300); line(470,300,470,275); line(470,275,150,275); line(465,150,155,150); line(155,150,155,275); line(150,300,150,275); line(150,295,145,295); line(145,295,145,290); line(145,290,150,290); line(465,150,465,275); rectangle(360,160,420,270); rectangle(389,160,391,270); setcolor(3); line(152,160,152,168); arc(465,265,270,90,5); arc(155,160,90,180,3); arc(155,168,180,270,3); setcolor(14); for i:=0 to 20 do circle(500,50,i); setcolor(9); rectangle(165,160,225,220); rectangle(230,160,290,220); rectangle(295,160,355,220); settextstyle(10,0,1); outtextxy(200,225,'seirosafar'); setfillstyle(9,11); bar3d(365,165,385,220,0,topon); bar3d(395,165,415,220,0,topon); bar3d(430,165,465,255,0,topon); setcolor(6); setfillstyle(6,10); bar3d(-1,380,800,600,1,topon); o:=100; for j:=0 to 5 do for i:=0 to 360 do begin if keypressed then begin chkey:=readkey; if ((chkey=ziad)and(o>0)) then o:=o-10; if (chkey=kam)and(o<200) then o:=o+10; if chkey=setare then begin for h:=0 to 20 do begin sound(704); setcolor(14); arc(470,265,270,90,5); arc(475,265,270,90,5); arc(467,265,270,90,2); arc(467,265,270,90,1); delay(5); setcolor(15); arc(470,265,270,90,5); arc(475,265,270,90,5); arc(467,265,270,90,2); arc(467,265,270,90,1); nosound; end; end; if chkey=space then halt(1); end; setcolor(14); circle(500,50,round(i/36)+22); setcolor(15); setfillstyle(9,15); bar3d(160-i+1,320,200-i+1,330,0,topon); bar3d(420-i+1,320,460-i+1,330,0,topon); bar3d(240-i+1,320,380-i+1,330,0,topon); bar3d(-20-i+1,320,120-i+1,330,0,topon); bar3d(500-i+1,320,640-i+1,330,0,topon); bar3d(680-i+1,320,720-i+1,330,0,topon); bar3d(760-i+1,320,900-i+1,330,0,topon); line(147,292,90,200); setcolor(15); arc(220,300,0-i,100-i,13); arc(400,300,0-i,100-i,13); setcolor(7); setfillstyle(9,7); bar3d(160-i,320,200-i,330,0,topon); bar3d(420-i,320,460-i,330,0,topon); bar3d(240-i,320,380-i,330,0,topon); bar3d(-20-i,320,120-i,330,0,topon); bar3d(500-i,320,640-i,330,0,topon); bar3d(680-i,320,720-i,330,0,topon); bar3d(760-i,320,900-i,330,0,topon); p:=(round(i/60)); ellipse(140-(4*p)-6,292,0,360,3,p+2); ellipse(140-(4*p)-2,292,0,360,3,p+1); ellipse(140-(4*p)+2,292,0,360,3,p); setcolor(1); arc(220,300,0-i,100-i,13); arc(400,300,0-i,100-i,13); delay(0); setcolor(6); k:=round(i/30)-3; setfillstyle(k,10); bar3d(-1,380,800,600,1,topon); setcolor(15); circle(500,50,(round(i/36)+22)); SETTEXTSTYLE(0,0,2); outtextxy(175+m,195,adamak); outtextxy(195+m,195,adamak1); arc(182+m,219,0,180,10); arc(202+m,219,0,180,10); setcolor(15); outtextxy(240+m,195,adamak); outtextxy(260+m,195,adamak1); arc(247+m,219,0,180,10); arc(267+m,219,0,180,10); setcolor(15); ellipse(140-(4*p)-6,292,0,360,3,p+2); ellipse(140-(4*p)-2,292,0,360,3,p+1); ellipse(140-(4*p)+2,292,0,360,3,p); outtextxy(305+m,195,adamak); outtextxy(325+m,195,adamak1); arc(312+m,219,0,180,10); arc(332+m,219,0,180,10); setcolor(6); m:=round(i/30); SETTEXTSTYLE(0,0,2); outtextxy(175+m,195,adamak); outtextxy(195+m,195,adamak1); arc(182+m,219,0,180,10); arc(202+m,219,0,180,10); setcolor(12); outtextxy(240+m,195,adamak); outtextxy(260+m,195,adamak1); arc(247+m,219,0,180,10); arc(267+m,219,0,180,10); setcolor(10); outtextxy(305+m,195,adamak); outtextxy(325+m,195,adamak1); arc(312+m,219,0,180,10); arc(332+m,219,0,180,10); delay(o); end; end; readln; closegraph end.
یک اتوبوس است که روی آن نوشته ((سیر و سفر)) و چند نفر آدم هم داخلش نشستند.
program pnigpong ;
uses graph;
const directory ='c:\tp\bgi';
var driver , mode,a : integer;
begin
a:=20 ;
initgraph ( driver , mode ,directory);
setbkcolor(1);
setcolor (15);
rectangle (100,50,500,250);{miz}
line (125,150,275,150);{khat samte chap}
line (325,150,475,150);{khat samte rast}
line (300,50,300,250); {khat amoodi}
setcolor (4);
bar (80,50,100,100);{rket chap}
setcolor (4);
bar (500,50,520,100);{raket rast}
settextstyle (3,horizdir,2);
setcolor (12);
outtextxy (278,60,'NIMJA');
setcolor (15);
settextstyle (1,horizdir,2);
outtextxy (130,220,'PLAYER 1');
settextstyle (1,horizdir,2);
outtextxy (380,220,'PLAYER 2');
readln;
closegraph
end.
program test1 ;
uses crt,graph;
var
Keypress : char ;
begin
WHILE Keypress<>'q' DO
begin
Keypress := readkey;
Writeln(Keypress);
if Keypress='a' then
begin
Writeln('raket pak shavad');
Writeln('az mokhtasate raket kam shavad');
Writeln('raket dar jaye jadid rasm shavad');
end;
end;
end.
program pnigpong ;
uses crt,graph;
const directory ='c:\tp\bgi';
cup = chr(72);
cdown = chr(80);
cesc = chr(27);
var driver,x,y, mode : integer;
chkey : char;
begin
x:=50;
y:=100;
initgraph ( driver , mode ,directory);
setbkcolor(1);
setcolor (15);
rectangle (100,50,500,250);{miz}
line (125,150,275,150);{khat samte chap}
line (325,150,475,150);{khat samte rast}
line (300,50,300,250); {khat amoodi}
setcolor (4);
setcolor (4);
bar (500,50,520,100);{raket rast}
settextstyle (3,horizdir,2);
setcolor (12);
outtextxy (278,60,'NIMJA');
setcolor (15);
settextstyle (1,horizdir,2);
outtextxy (130,220,'PLAYER 1');
settextstyle (1,horizdir,2);
outtextxy (380,220,'PLAYER 2');
[B]repeat
begin
chkey :=readkey;
if chkey=cdown then
begin
SETFILLSTYLE (0,1);
BAR (80,50,99,Y) ;
x:=x+2;
y:=y+2;
SETFILLSTYLE (1,15);
BAR (80,x,99,y);{raket chap}
end;
end;
until chkey=cesc;
[/B]readln;
closegraph
end.
program graphics;
Uses
Crt, Graph;
var
depth,directionr,directionu,y,ballxpos,ballypos : integer;
GraphDriver, GraphMode : Integer;
randyc,randxc,randy,randx:integer;
x1,y1,dec1,dec2,dec3,dec4,dec5,x2,x3,x4,x5,y2,y3,y4,y5: integer;
x6,y6,dec6,dec7,dec8,dec9,dec10,x7,x8,x9,x10,y7,y8,y9,y10,y11,x11,dec11:integer;
key:char;
p1xpos,p1ypos,p2xpos,p2ypos:integer;
turn,p1turn,p2turn,p1score,p2score:integer;
procedure clear;
begin
setfillstyle(1,0);
bar(290,150,320,380);
end;
procedure eraseall;
begin
setfillstyle(1,0);
bar(1,1,640,480);
end;
procedure opening;
begin
x1:=200;
y1:=200;
x2:=250;
y2:=200;
x3:=300;
y3:=200;
x4:=350;
y4:=200;
x5:=400;
y5:=200;
x6:=200;
y6:=300;
x7:=250;
y7:=300;
x8:=300;
y8:=300;
x9:=350;
y9:=300;
x10:=400;
y10:=300;
x11:=430;
y11:=300;
dec1:=400;
dec2:=400;
dec3:=400;
dec4:=400;
dec5:=400;
dec6:=400;
dec7:=400;
dec8:=400;
dec9:=400;
dec10:=400;
dec11:=400;
setcolor(12);
settextstyle(10,0,2);
outtextxy(280,150,'R');
outtextxy(280,190,'O');
outtextxy(280,230,'C');
outtextxy(280,270,'K');
setcolor(10);
outtextxy(280,310,'E');
setcolor(12);
outtextxy(280,350,'T');
outtextxy(320,150,'S');
outtextxy(320,190,'Q');
outtextxy(320,230,'U');
outtextxy(320,270,'A');
setcolor(10);
outtextxy(320,310,'S');
setcolor(12);
outtextxy(320,350,'H');
setcolor(10);
outtextxy(180,310,'G');
outtextxy(210,310,'A');
outtextxy(240,310,'M');
repeat
dec1:=dec1 - 1;
dec2:=dec2 - 1;
dec3:=dec3 - 1;
dec4:=dec4 - 1;
dec5:=dec5 - 1;
dec6:=dec6 - 1;
dec7:=dec7 - 1;
dec8:=dec8 - 1;
dec9:=dec9 - 1;
dec10:=dec10 - 1;
dec11:=dec11 - 1;
setcolor(random(15)+1);
circle(x1,y1,dec1);
circle(x2,y2,dec2);
circle(x3,y3,dec3);
circle(x4,y4,dec4);
circle(x5,y5,dec5);
circle(x6,y6,dec6);
circle(x7,y7,dec7);
circle(x8,y8,dec8);
circle(x9,y9,dec9);
circle(x10,y10,dec10);
circle(x11,y11,dec11);
delay(6);
setcolor(0);
circle(x1,y1,dec1);
circle(x2,y2,dec2);
circle(x3,y3,dec3);
circle(x4,y4,dec4);
circle(x5,y5,dec5);
circle(x6,y6,dec6);
circle(x7,y7,dec7);
circle(x8,y8,dec8);
circle(x9,y9,dec9);
circle(x10,y10,dec10);
circle(x11,y11,dec11);
if dec1 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x1-15,y1-50,'');
end;
if dec2 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x2-15,y2-50,'');
end;
if dec3 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x3-15,y3-50,'');
end;
if dec4 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x4-15,y4-50,'');
end;
if dec5 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x5-15,y5-50,'');
end;
if dec6 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x6-15,y6-50,'S');
end;
if dec7 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x7-15,y7-50,'Q');
end;
if dec8 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x8-15,y8-50,'U');
end;
if dec9 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x9-15,y9-50,'A');
end;
if dec10 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x10-15,y10-50,'S');
end;
if dec11 <=0 then
begin
setcolor(random(15)+1);
settextstyle(10,0,5);
outtextxy(x11-1,y11-50,'H');
end;
until keypressed;
end;
procedure restrict;
begin
if ballxpos <=120 then
begin
directionr := 0;
end;
if ballxpos >=500 then
begin
directionr := 180;
end;
if (ballypos<=230) then
begin
directionu := 270;
end;
end;
procedure ball;
var i :integer;
begin
setbkcolor(0);
{back left corner}
setfillstyle(1,15);
bar(1,70,2,470);
{back left corner}
bar(620,91,621,470);
setfillstyle(1,12);
bar(120,180,500,181);
bar(121,310,500,311);
{outline front wall}
bar(120,1,500,2);
{center court line}
bar(41,430,578,431);
{left service box}
bar(1,471,111,472);
{right service box}
bar(490,471,621,472);
setcolor(12);
{left service box diagonal}
line(151,431,111,471);
line(151,432,111,472);
line(151,433,111,473);
{right service box diagonal}
line(460,431,490,471);
line(460,432,490,472);
line(460,433,490,473);
{center court on floor line}
line(299,430,299,481);
line(300,431,300,482);
line(301,432,301,483);
{____}
setcolor(15);
line(1,470,120,350);
{left corner front wall}
line(120,350,120,1);
{right corner front wall}
line(500,350,500,1);
{base of tin}
line(120,351,500,351);
{right nick}
line(500,351,620,471);
{left outline left wall}
setcolor(12);
line(1,70,120,1);
{right outline right wall}
line(500,1,620,91);
setbkcolor(0);
delay(3);
setcolor(15);
circle(ballxpos,ballypos,depth);
setfillstyle(1,15);
floodfill(ballxpos,ballypos,15);
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos+50,p1ypos+50);
setfillstyle(1,10);
bar(p2xpos,p2ypos,p2xpos+50,p2ypos+50);
delay(9);
setcolor(0);
circle(ballxpos,ballypos,depth);
setfillstyle(1,0);
floodfill(ballxpos,ballypos,0);
restrict;
end;
procedure increases;
begin
randy:=random(5)+3;
randx:=random(7)+4;
end; {}
procedure directions;
begin
randyc:=random(3)+1;
if randyc = 1 then directionu:=90;
if randyc = 2 then directionu:=270;
randxc:=random(3)+1;
if randxc = 1 then directionr:=0;
if randxc = 2 then directionr:=180;
end;
{ }
procedure players;
begin
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos+50,p1ypos+50);
setfillstyle(1,14);
bar(p2xpos,p2ypos,p2xpos+50,p2ypos+50);
if key = 'w' then
begin
p1ypos:=p1ypos - 40;
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos +50,p1ypos+50);
setfillstyle(0,0);
bar(p1xpos,p1ypos+50,p1xpos + 50,p1ypos+100);
end;
if key = 's' then
begin
p1ypos:=p1ypos + 40;
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos +50,p1ypos+50);
setfillstyle(0,0);
bar(p1xpos,p1ypos,p1xpos + 50,p1ypos-50);
end;
if key = 'a' then
begin
p1xpos:=p1xpos - 40;
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos +50,p1ypos+50);
setfillstyle(0,0);
bar(p1xpos+50,p1ypos,p1xpos + 100,p1ypos+50);
end;
if key = 'd' then
begin
p1xpos:=p1xpos + 40;
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos +50,p1ypos+50);
setfillstyle(0,0);
bar(p1xpos,p1ypos,p1xpos - 50,p1ypos+50);
end;
{player2 keys}
if key = 'i' then
begin
p2ypos:=p2ypos - 40;
setfillstyle(1,10);
bar(p2xpos,p2ypos,p2xpos +50,p2ypos+50);
setfillstyle(0,0);
bar(p2xpos,p2ypos+50,p2xpos + 50,p2ypos+100);
end;
if key = 'k' then
begin
p2ypos:=p2ypos + 40;
setfillstyle(1,10);
bar(p2xpos,p2ypos,p2xpos +50,p2ypos+50);
setfillstyle(0,0);
bar(p2xpos,p2ypos,p2xpos + 50,p2ypos-50);
end;
if key = 'j' then
begin
p2xpos:=p2xpos - 40;
setfillstyle(1,10);
bar(p2xpos,p2ypos,p2xpos +50,p2ypos+50);
setfillstyle(0,0);
bar(p2xpos+50,p2ypos,p2xpos + 100,p2ypos+50);
end;
if key = 'l' then
begin
p2xpos:=p2xpos + 40;
setfillstyle(1,10);
bar(p2xpos,p2ypos,p2xpos +50,p2ypos+50);
setfillstyle(0,0);
bar(p2xpos,p2ypos,p2xpos - 50,p2ypos+50);
end;
if p1xpos < 10 then p1xpos := 10;
if p1xpos > 590 then p1xpos := 590;
if p1ypos > 430 then p1ypos := 430;
if p1ypos < 10 then p1ypos := 10;
if p2xpos < 10 then p2xpos := 10;
if p2xpos > 590 then p2xpos := 590;
if p2ypos > 430 then p2ypos := 430;
if p2ypos < 10 then p2ypos := 10;
end;
begin
GraphDriver := Detect;
InitGraph(GraphDriver, GraphMode, 'c:\tp\bgi');
if GraphResult <> grOk then Halt(1);
Randomize;
{starting position}
ballxpos:=320;
ballypos:=250;
{depth}
opening;
eraseall;
depth:=1;
p1score:=0;
p2score:=0;
p1xpos:=280;
p1ypos:=200;
p2xpos:=360;
p2ypos:=200;
setbkcolor(0);
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos+50,p1ypos+50);
setfillstyle(1,10);
bar(p2xpos,p2ypos,p2xpos+50,p2ypos+50);
p1turn:=1;
p2turn:=0;
directions;
ball;
delay(1300); {sssssddd}
repeat
bar(121,310,500,311);
line(120,350,120,1);
{if (depth <=7) then if (ballypos <= 352) and (ballypos >=308) then
begin
eraseall;
setcolor(12);
outtextxy(250,200,'Tin shot!!!');
turn:=0;
readln;
halt(1);
end;}
if keypressed then
begin
key:=readkey;
players;
end;
{ball bigger start}
if depth <= 3 then
begin
directions;
setfillstyle(1,9);
bar(p1xpos,p1ypos,p1xpos+50,p1ypos+50);
setfillstyle(1,10);
bar(p2xpos,p2ypos,p2xpos+50,p2ypos+50);
turn:=1;
repeat
depth:=depth + 3;
ball;
if keypressed then
begin
key:=readkey;
players;
end;
if (directionr = 180) then
begin
increases;
ballxpos:=ballxpos - randx;
ball;
restrict;
end;
if (directionr = 0) then
begin
increases;
ballxpos:=ballxpos + randx;
ball;
restrict;
end;
if (directionu = 90) then
begin
increases;
ballypos:=ballypos - randy;
ball;
restrict;
end;
if (directionu = 270) then
begin
increases;
ballypos:=ballypos + randy;
ball;
restrict;
end;
restrict;
until (depth >= 20) or(p1score = 9) or (p2score = 9) or (key = chr(27));
end;
{ball bigger end}
{ball smaller start}
if (depth >= 20)and ((p1turn = 1)or (p2turn = 0)) then if ((ballxpos >=p1xpos-10) and (ballxpos <=p1xpos +65)) then
if (ballypos >=p1ypos-10) and (ballypos <= p1ypos + 75) then
begin
p1turn:=0;
p2turn:=1;
directionu:=90; { }
sound(500);
delay(10);
nosound;
repeat
depth:=depth - 1;
ball;
if keypressed then
begin
key:=readkey;
players;
end;
if (directionr = 180) then
begin
increases;
ballxpos:=ballxpos - randx;
ball;
restrict;
end;
if (directionr = 0) then
begin
increases;
ballxpos:=ballxpos + randx;
ball;
restrict;
end;
if (directionu = 90) then
begin
increases;
ballypos:=ballypos - randy;
ball;
restrict;
end;
if (directionu = 270) then
begin
increases;
ballypos:=ballypos + randy;
ball;
restrict;
end;
restrict;
until (depth <= 3) or(key = chr(27))or (turn = 0);
{ball smaller start}
end
else
begin
eraseall;
setcolor(10);
outtextxy(200,200,'Player 2 wins');
readln;
halt(1);
end;
if (depth >= 20)and ((p2turn = 1)or (p1turn = 0)) then if ((ballxpos >=p2xpos-10) and (ballxpos <=p2xpos +65)) then
if (ballypos >=p2ypos-10) and (ballypos <= p2ypos + 75) then
begin
p1turn:=1;
p2turn:=0;
directionu:=90; { }
sound(500);
delay(10);
nosound;
repeat
depth:=depth - 3;
ball;
if keypressed then
begin
key:=readkey;
players;
end;
if (directionr = 180) then
begin
increases;
ballxpos:=ballxpos - randx;
ball;
restrict;
end;
if (directionr = 0) then
begin
increases;
ballxpos:=ballxpos + randx;
ball;
restrict;
end;
if (directionu = 90) then
begin
increases;
ballypos:=ballypos - randy;
ball;
restrict;
end;
if (directionu = 270) then
begin
increases;
ballypos:=ballypos + randy;
ball;
restrict;
end;
restrict;
until (depth <= 3) or (key = chr(27)) or (turn = 0);
{ball smaller start}
end
else
begin
eraseall;
setcolor(9);
outtextxy(200,200,'Player 1 wins');
readln;
halt(1);
end;
{}
until (key = chr(27)) or(turn = 0);
end.
Uses Graph; {Enables access to graphics modules and constants}
Var
Driver, Mode: integer; {Indicators of kind of graphics hardware}
InitGraph (Driver, Mode, 'C:\BP\BGI'); {Initialize graphics mode}
BigX := GetMaxX;
BigY := GetMaxY;
Program showDimensions;
{Displays Palette dimensions}
Uses graph; {Enables access to graphics modules and constants.}
Const
Directory = 'c:\BP\BGI'; {Name of graphics directory}
Var
Driver, Mode: integer; {Indicators of kind of graphics hardware}
BigX, BigY: integer;
Begin {showDimensions}
InitGraph (Driver, Mode, Directory); {Initialize graphics mode}
BigX := GetMaxX;
BigY := GetMaxY;
CloseGraph;
Writeln ('Pixel at Bottom-right corner is (', BigX :1, ', ', BigY :1, ')')
End; {showDimensions}
Setbkcolor (Green); {green is the background color.}
Setcolor (red) {Red is the Foreground color.}
Line (X1, Y1, X2, Y2)
Program Intersect;
{Draw intersecting lines}
Uses graph; {Enables access to graphics modules and constants.}
Const
Directory = 'c:\BP\BGI'; {Name of graphics directory}
Var
Driver, Mode: integer; {Indicators of kind of graphics hardware}
Begin {Intersect}
InitGraph (Driver, Mode, Directory); {Initialize graphics mode}
Line (0, 0, GetMaxX, GetMaxY);
Setcolor (Lightgray);
Line (GetMaxX, 0, 0, GetMaxY);
End. {Intersect}
Rectangle (x1, y1, x2, y2)
Program house;
{Draw a house}
Uses graph; {Enables access to graphics modules and constants.}
Const
Directory = 'c:\BP\BGI'; {Name of graphics directory}
Var
Driver, Mode: integer; {Indicators of kind of graphics hardware}
X1, Y1, X2, Y2, X3, Y3,
X4, Y4, X5, Y5, X6, Y6: integer;
Begin {house}
InitGraph (Driver, Mode, Directory); {Initialize graphics mode}
X1:=100; Y1:=200;
X2:=300; Y2:=100;
X3:=500; Y3:=200;
X4:=500; Y4:=400;
X5:=325; Y5:=400;
X6:=275; Y6:=325;
Line (x1, y1, x2, y2);
Line (X2, y2, x3, y3);
Rectangle (x1, y1, X4, Y4);
Rectangle (X5, Y5, X6, Y6);
End. {House}
Circle (x, y, Radius)
Arc (X, Y, 180, Radius)
Program HappyFace;
{Draw a happy Face}
Uses graph; {Enables access to graphics modules and constants.}
Const
Directory = 'c:\BP\BGI'; {Name of graphics directory}
Var
Driver, Mode: integer; {Indicators of kind of graphics hardware}
MidX, MidY, LeftEyeX, RightEyeX, EyeY, NoseX, NoseY,
HeadRadius, EyeNoseRadius, SmileRadius, StepX, StepY :Intrger;
Begin
InitGraph (Driver, Mode, Directory); {Initialize graphics mode}
MidX :=GetMaxX div 2;
MidY :=GetMaxY div 2;
HeadRadius := GetMaxY div 4;
Circle (MidX, MidY,);
StepX := HeadRadius div 4;
setpY := stepX;
leftEyeX := MidX- StepX;
RightEyeX := MidX+ StepX;
EyeY := MidY-setpY;
EyeNoseRadius := HeadRadius div 10;
Circle (leftEyeX, EyeY, EyeNoseRadius);
Circle (RightEyeX, EyeY, EyeNoseRadius);
NoseX := MidX;
NoseY :=MidY + stepY;
Circle (NoseX, NoseY, EyeNoseRadius);
SmileRadius := Round(0.75 * HeadRadius);
Arc (MidX, MidY, 210,330, SmileRadius)
End.
X1 := GetMaxX div 4 ; Y1 := GetMaxY div 2;
X2 := GetMaxX div 2 ; Y2 := Get MaxY div 4;
SetFillStyle (SlashFill, Red)
SetFillStyle (HatchFill, LightGray);
FloodFill (X2, Y2+10, White);
SetFillStyle (LineFill, White);
FloodFill (X2, Y2+10, White);
SetFillStyle (SolidFill, Blue);
FloodFill (X2, Y2+10, White);
SetFillStyle (XHAtchFill, White);
Bar (X1, Y1, X2, Y2)
SetFillStyle (XHatchFill, White);
PieSlice (MidX, MidY, 10, 60, SmileRadius)
OutTextXY (MidX – HeadRadius, GetMaXY – 20, 'Text')
Uses graph;
var
grdriver,grmode,errcode:integer;
begin
grdriver:=detect;
{این دستور میگه بهترین مد گرافیکی درایو را انتخاب کن}
initgraph(grdriver,grmode,'c:\tp\bgi');
{ آدرس جایی که توربوپاسکال نصب است را می نویسیم.}
errcode:=graphresult;
if errcode<>grok then
halt;
.
.
.
cleardevice;
Setbkcolor(color:word);
Closegraph;
) ;شعاع,زاویه پایانی,زاویه شروعArc(x:integer,y:integer,
Circle(x:integer,y:integer, شعاع) ;
Line(x,y,x1,y1);
Putpixel(x,y,شماره رنگ از 0 تا 15 );
Rectangle(x1,y1,x2,y2:integer);
Setcolor(شماره رنگ از 0 تا 15 );
Bar(x1,y1,x2,y2);
Bar3d(x1,y1,x2,y2,depth,topon);
Setfillstyle الگو), رنگ ) ;
Setlinestyle(linestyle,الگو ,ضخامت);
Outtext(‘ یک نوشته ‘);
Outtextxy(x,y,’ یک نوشته ‘);
Settextstyle(فونت,جهت نوشتن متن,اندازه کارکترها);
Lineto(x,y);
rogram pnigpong ;
uses crt,graph;
const directory ='c:\tp\bgi';
cup = chr(72);
cdown = chr(80);
cesc = chr(27);
var driver,x,y,xc,yc,limy,limx, mode : integer;
chkey : char;
begin
x:=50;
y:=100;
xc:=300;
yc:=150;
limy:=1;
limx:=1;
initgraph ( driver , mode ,directory);
setfillstyle (1,1);
bar (100,50,500,250);{miz}
setfillstyle (1,4);
bar (501,x,520,y);{raket rast}
BAR (80,x,99,y); {raket chap}
{rasme toop}
setcolor(15);
circle (300,150,5);
setfillstyle(1,15 );
floodfill(300,150,15);
[B]{bakhshe harekat}
repeat
begin
{harekat toop}
if yc>=245 THEN
limy:=limy*(-1);
if yc<=55 then
limy:=limy*(-1);
if xc>=495 then
limx:=limx*(-1);
if xc<=105 then
limx:=limx*(-1);
xc:=xc+limx;
yc:=yc+limy;
setfillstyle (1,1);
bar (100,50,500,250);{miz}
setcolor(15);
circle (xc,yc,5);
setfillstyle(1,15 );
floodfill(xc,yc,15);
chkey :=readkey;
{key}
if chkey=cdown then
begin
SETFILLSTYLE (0,0);
BAR (80,50,99,250) ;
BAR (501,50,520,250) ;
x:=x+2;
y:=y+2;
SETFILLSTYLE (1,4 );
BAR (80,x,99,y);{raket chap}
bar (501,x,520,y)
end;
if chkey=cup then
begin
SETFILLSTYLE (0,0);
BAR (80,50,99,250) ;
BAR (501,50,520,250) ;
x:=x-2;
y:=y-2;
SETFILLSTYLE (1,4);
BAR (80,x,99,y);{raket chap}
bar (501,x,520,y)
end;
end;
until chkey=cesc[/B];
readln;
closegraph
end.
program test1 ;
uses crt,graph;
var
Keypress : char ;
begin
WHILE Keypress<>'q' DO
begin
if keypressed then
begin
Keypress := readkey;
if Keypress='a' then
begin
Writeln('raket pak shavad');
Writeln('az mokhtasate raket kam shavad');
Writeln('raket dar jaye jadid rasm shavad');
end;
end;
Writeln(Keypress);
{circle move here}
end;
end.