📄 模拟扫雷游戏.htm
字号:
NULL)/*不能新建就提示错误并退出*/<BR>
{<BR>
printf("The file cannot
open!\n");<BR>
printf("Presss any key to
exit!\n");<BR>
getch();closegraph();<BR>
exit(1);<BR>
}
/*写入初始内容*/<BR>
fprintf(fp,"%d %d
%d,%s\n%s\n%s\n",222,555,999,"GaoShou","KuaiLei","DeYi");<BR>
fclose(fp);
<BR>
}<BR>}</P>
<P>int Record()<BR>{ FILE *fp; <BR>
char cco[3][4];<BR> int i;<BR>
for(i=0;i<3;i++)<BR>
cco[i][3]='\0'; <BR> if((fp =
fopen("Record", "r"))!=NULL)
<BR> { fscanf(fp,"%d %d
%d,",&lev[0],&lev[1],&lev[2]);<BR>
for(i=0;i<3;i++)<BR>
fscanf(fp,"%s\n",name[i]);
<BR>
fclose(fp);<BR>
setcolor(15);<BR>
outtextxy(225,80,"HighCore");<BR>
setcolor(LIGHTGREEN);<BR>
outtextxy(200,100,"Level");<BR>
outtextxy(250,100,"Time");<BR>
outtextxy(300,100,"Name");<BR>
setcolor(GREEN);<BR>
outtextxy(200,120,"Easy");<BR>
outtextxy(200,140,"Normal");<BR>
outtextxy(200,160,"Hard");<BR>
for(i=0;i<3;i++)<BR>
{<BR>
cco[i][0]=(lev[i]-lev[i]%100)/100+48;<BR>
cco[i][1]=(lev[i]%100-lev[i]%10)/10
+48;<BR>
cco[i][2]=lev[i]%10+48;<BR>
}</P>
<P>
setcolor(YELLOW);<BR>
outtextxy(250,120,cco[0]);<BR>
outtextxy(250,140,cco[1]);<BR>
outtextxy(250,160,cco[2]);</P>
<P>
setcolor(RED);<BR>
outtextxy(300,120,name[0]);<BR>
outtextxy(300,140,name[1]);<BR>
outtextxy(300,160,name[2]);
<BR> }<BR>}</P>
<P>int BreakRecord()<BR>{ FILE *
fp;<BR> char n[20];<BR>
int i;<BR> if((fp =
fopen("Record", "r")) !=
NULL)<BR> { fscanf(fp,"%d
%d
%d,",&lev[0],&lev[1],&lev[2]);<BR>
for(i=0;i<3;i++)<BR>
fscanf(fp,"%s\n",name[i]);<BR>
fclose(fp);<BR> }
<BR> if(lev[l]>ti)<BR> {
setfillstyle(1,BLUE);
<BR>
bar(300,300,560,350);
<BR>
setcolor(LIGHTGREEN);<BR>
outtextxy(310,310,"You are break the record!");
<BR>
outtextxy(310,320,"Please input your name(0 -
19)"); <BR>
outtextxy(310,340,"Name:");<BR>
for(i=0;i<20;i++)<BR>
{<BR>
n[i]=getch();<BR>
n[i+1]='\0';<BR>
if(n[i]==13)<BR>
break;<BR>
setfillstyle(1,BLUE);<BR>
bar(350,339,559,345);<BR>
setcolor(RED);<BR>
outtextxy(350,340,n);<BR>
} <BR>
strcpy(name[l],n);lev[l]=ti;
<BR> if((fp =
fopen("Record", "w"))!=NULL)
<BR> {
fprintf(fp,"%d %d
%d,",lev[0],lev[1],lev[2]);<BR>
for(i=0;i<3;i++)<BR>
fprintf(fp,"%s\n",name[i]);<BR>
fclose(fp);<BR>
}<BR>
setfillstyle(1,0);
<BR>
bar(300,300,560,350);<BR>
<BR> }<BR>
else<BR> {
<BR>
setcolor(YELLOW);<BR>
outtextxy(450,350,"You are
Sucess!");<BR>
setcolor(GREEN);<BR>
outtextxy(450,360,"Please any
key.....");<BR>
}<BR> <BR>} </P>
<P>void main()<BR>{int
gd=DETECT,gm,k=1;<BR> initgraph(&gd,&gm,"c:\\tc");<BR> randomize();<BR> MouseSetY(0,479);<BR> MouseSetX(0,639);<BR> MouseSetXY(100,100);<BR> CreatFile();<BR> star:
Levle();<BR> loop:
picture();<BR> setcolor(LIGHTGREEN);<BR> outtextxy(50,410,"SPACE
: Restar"); <BR> outtextxy(220,410,"ESC :
Exit"); <BR> outtextxy(350,410,"F2 : Menu");
<BR> outtextxy(70,20,"time :");
<BR> outtextxy(200,20,"bombs :");
<BR> randbomb();<BR> MouseOn(MouseX,MouseY);/*第一次显示鼠标*/<BR> tt=0;<BR> while(1)<BR> {
<BR>
while(bioskey(1)!=0)<BR>
{
key=bioskey(0);<BR>
switch(key)<BR>
{
<BR>
case F2:
tt=0;<BR>
cleardevice();
/******选择菜单*************/<BR>
goto
star;<BR>
<BR>
case SPACE : MouseOff();
/*******从开一局**************/<BR>
goto loop;
<BR>
<BR>
case ESC : closegraph();exit(0);
/***退出******/<BR>
} <BR> }<BR>
switch(MouseStatus())<BR>
{<BR> case 1: MouseOff();
/*左键*/<BR>
if(win==1)
/*****没失败********/<BR>
{
locate();<BR>
if(b[v].color==RED)<BR>
{ if(b[v].mark==1) Failure();
/******点中雷******/<BR>
else
<BR>
if(b[v].bomb==0)
/*******此位置周围的雷数为0,自开******/<BR>
Open();<BR>
else
<BR> &n
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -