我的第一个graph小游戏
uses graph,crt;
var gd,gm:smallint;s,n,m,i,g:longint;st:string;
procedure print(x,y:longint);
var i,j:longint;
begin
sector(y+50,x+50,0,180,40,70);
for i:=-3 to 3 do
begin
for j:=35 to 40 do
putpixel(y+j,x+i,red);
for j:=60 to 65 do
putpixel(y+j,x+i,red);
end; end;
begin
gd:=detect;initgraph(gd,gm,'');setbkcolor(green);cleardevice;
setcolor(red);settextstyle(7,horizdir,6);outtextxy(130,100,'Whac-A-Mole');
settextstyle(3,horizdir,3);outtextxy(100,300,'Pressed Enter to coutinue');
readln;setbkcolor(red);s:=0;
repeat
cleardevice;
setcolor(green);
str(s,st);settextstyle(5,horizdir,5);outtextxy(10,10,st);
circle(200,200,50);circle(200,400,50);circle(200,600,50);
circle(400,200,50);circle(400,400,50);circle(400,600,50);
circle(600,200,50);circle(600,400,50);circle(600,600,50);
randomize;
n:=random(9)+1;
case n of
1:print(150,150);
2:print(150,350);
3:print(150,550);
4:print(350,150);
5:print(350,350);
6:print(350,550);
7:print(550,150);
8:print(550,350);
9:print(550,550);
end;
str(n,st);outtextxy(1,500,st);
for i:=1 to (10-g)*200 do
if keypressed then
begin val(readkey,m);if(n=m)then
begin s:=s+100;break;end;end
else delay(1);
g:=s div 500;
until s=5000;
settextstyle(10,horizdir,9);
outtextxy(100,100,'YOU ARE WIN!');
readln;
end.
uses graph,crt;
var gd,gm:smallint;s,n,m,i,g:longint;st:string;
procedure print(x,y:longint);
var i,j:longint;
begin
sector(y+50,x+50,0,180,40,70);
for i:=-3 to 3 do
begin
for j:=35 to 40 do
putpixel(y+j,x+i,red);
for j:=60 to 65 do
putpixel(y+j,x+i,red);
end; end;
begin
gd:=detect;initgraph(gd,gm,'');setbkcolor(green);cleardevice;
setcolor(red);settextstyle(7,horizdir,6);outtextxy(130,100,'Whac-A-Mole');
settextstyle(3,horizdir,3);outtextxy(100,300,'Pressed Enter to coutinue');
readln;setbkcolor(red);s:=0;
repeat
cleardevice;
setcolor(green);
str(s,st);settextstyle(5,horizdir,5);outtextxy(10,10,st);
circle(200,200,50);circle(200,400,50);circle(200,600,50);
circle(400,200,50);circle(400,400,50);circle(400,600,50);
circle(600,200,50);circle(600,400,50);circle(600,600,50);
randomize;
n:=random(9)+1;
case n of
1:print(150,150);
2:print(150,350);
3:print(150,550);
4:print(350,150);
5:print(350,350);
6:print(350,550);
7:print(550,150);
8:print(550,350);
9:print(550,550);
end;
str(n,st);outtextxy(1,500,st);
for i:=1 to (10-g)*200 do
if keypressed then
begin val(readkey,m);if(n=m)then
begin s:=s+100;break;end;end
else delay(1);
g:=s div 500;
until s=5000;
settextstyle(10,horizdir,9);
outtextxy(100,100,'YOU ARE WIN!');
readln;
end.
