📄 fyrad.c
字号:
main();
getch();
}
void winregister(int victory)
{
if(victory == 1){
setcolor(BLUE);
rectangle(100,60,420,100);
setfillstyle(SOLID_FILL,BLACK);
floodfill(90,80,BLUE);
setcolor(YELLOW);
moveto(105,65);
settextstyle(1,0,1);
outtext("You WIN!Press any key to continue.");
}
if(victory == 2){
setcolor(BLUE);
rectangle(100,60,420,100);
setfillstyle(SOLID_FILL,BLACK);
floodfill(90,80,BLUE);
setcolor(YELLOW);
moveto(105,65);
settextstyle(1,0,1);
outtext("I Win!Press any key to continue.");
}
if(victory == 3){
setcolor(BLUE);
rectangle(100,60,420,100);
setfillstyle(SOLID_FILL,BLACK);
floodfill(90,80,BLUE);
setcolor(YELLOW);
moveto(140,65);
settextstyle(1,0,1);
outtext("Draw(Press any key to continue.)");
}
}
void flash(int i,int j,int k){
int x;
for(x=0;x<=501+k;x++){
if(x%2==0){setfillstyle(SOLID_FILL,RED);
floodfill((j+3)*40,(i+3)*40,BLUE);}
if(x%2==1){setfillstyle(SOLID_FILL,YELLOW);
floodfill((j+3)*40,(i+3)*40,BLUE);}
}
}
void flashcolor(int i,int j,int k){
int x;
for(x=0;x<=501+k;x++){
if(x%2==0){setfillstyle(SOLID_FILL,WHITE);
floodfill((j+3)*40,(i+3)*40,BLUE);}
if(x%2==1){setfillstyle(SOLID_FILL,LIGHTRED);
floodfill((j+3)*40,(i+3)*40,BLUE);}
}
}
void help(void){
int i,j;
setcolor(BLUE);
rectangle(0,10,360,275);
setfillstyle(SOLID_FILL,BLACK);
floodfill(20,20,BLUE);
setcolor(BLUE);
settextstyle(2,0,5);
for(i=0;i<=328;i++){
if(i%2==0){
j=i/2;
j=j%15;
setcolor(j);
outtextxy(20,60-20,"Use the keyboard to put the chessman, ");
outtextxy(20,110-20,"get four pieces of the same color in a");
outtextxy(20,160-20,"row in all directions (horizontal,ve");
outtextxy(20,210-20,"-rtical or diagonal),then you'll win.");
outtextxy(40,260-10,"Press any key to continue.");
}
if(i%2==1){
setcolor(15);
outtextxy(20,60-20,"Use the keyboard to put the chessman, ");
outtextxy(20,110-20,"get four pieces of the same color in a");
outtextxy(20,160-20,"row in all directions (horizontal,ve");
outtextxy(20,210-20,"-rtical or diagonal),then you'll win.");
outtextxy(40,260-10,"Press any key to continue.");
}
}
}
void shortkey(void){
int i,j;
setcolor(BLUE);
rectangle(0,10,360,275);
setfillstyle(SOLID_FILL,BLACK);
floodfill(20,20,BLUE);
setcolor(BLUE);
settextstyle(2,0,5);
for(i=0;i<=328;i++){
if(i%2==0){
j=i/2;
j=j%15;
setcolor(j);
outtextxy(20,60-20,"ENTER: Put a chessman on the chessboard.");
outtextxy(20,110-20,"RIGHT & LEFT: Move a chessman of yours. ");
outtextxy(20,160-20,"DOWN: Save game. ");
outtextxy(20,210-20,"ESC: Return to the menu. ");
outtextxy(40,260-10,"Press any key to continue.");
}
if(i%2==1){
setcolor(15);
outtextxy(20,60-20, "ENTER: Put a chessman on the chessboard.");
outtextxy(20,110-20,"RIGHT & LEFT: Move a chessman of yours. ");
outtextxy(20,160-20,"DOWN: Save game. ");
outtextxy(20,210-20,"ESC: Return to the menu. ");
outtextxy(40,260-10,"Press any key to continue.");
}
}
}
void save(void){
int i,j;
setcolor(BLUE);
rectangle(0,10,360,275);
setfillstyle(SOLID_FILL,BLACK);
floodfill(20,20,BLUE);
setcolor(BLUE);
settextstyle(2,0,5);
for(i=0;i<=328;i++){
if(i%2==0){
j=i/2;
j=j%15;
setcolor(j);
outtextxy(20,60-20,"If you wangt to save the game, ");
outtextxy(20,110-20,"when you are playing. ");
outtextxy(20,160-20,"Please press the key 'DOWN' , ");
outtextxy(20,210-20,"After you put a chessman. ");
outtextxy(40,260-10,"Press any key to continue.");
}
if(i%2==1){
setcolor(15);
outtextxy(20,60-20,"If you wangt to save the game, ");
outtextxy(20,110-20,"when you are playing. ");
outtextxy(20,160-20,"Please press the key 'DOWN' , ");
outtextxy(20,210-20,"After you put a chessman. ");
outtextxy(40,260-10,"Press any key to continue.");
}
}
}
void change(void){
int i,j;
setcolor(BLUE);
rectangle(0,10,360,275);
setfillstyle(SOLID_FILL,BLACK);
floodfill(20,20,BLUE);
setcolor(BLUE);
settextstyle(2,0,5);
for(i=0;i<=328;i++){
if(i%2==0){
j=i/2;
j=j%15;
setcolor(j);
outtextxy(20,60-20,"If you want to change the color of chessman,");
outtextxy(20,110-20,"please press the button 'Color'. ");
outtextxy(20,160-20,"If you want to change the level of game,");
outtextxy(20,210-20,"please press the button 'Level'. ");
outtextxy(40,260-10,"Press any key to continue.");
}
if(i%2==1){
setcolor(15);
outtextxy(20,60-20,"If you want to change the color of chessman,");
outtextxy(20,110-20,"please press the button 'Color'. ");
outtextxy(20,160-20,"If you want to change the level of game,");
outtextxy(20,210-20,"please press the button 'Level'. ");
outtextxy(40,260-10,"Press any key to continue.");
}
}
}
void newpicture(void){
int k;
setviewport(100,80,475,475,1);
setcolor(BLUE);
rectangle(0,10,360,275);
setfillstyle(SOLID_FILL,BLACK);
floodfill(20,20,BLUE);
setcolor(14);
settextstyle(2,0,8);
outtextxy(20,60-20,"Welcome to Fyrad 32 ! ");
setcolor(8);
settextstyle(2,0,5);
outtextxy(20,110-20," Name:hehe ");
outtextxy(20,160-20," Number:301 ");
outtextxy(20,210-20," Teacher:Zhoujun ");
outtextxy(40,260-10,"Press any key to continue.");
k=specialkey();
cleardevice();
}
void small_main(){
int i=1;
int j=3;
int k;
k=small_menu(i,j);
do{
if(k==1||k==2){k=small_menu(k,j);}
if(k==3||k==4){k=small_menu(i,k);}
}while(k==1||k==2||k==3||k==4);
}
int small_menu(int a, int c)
{
int driver,mode;
int setview_sx = 170,setview_sy = 120,setview_ex,setview_ey;
int key1,key2;
int h[6][6];
int b[6][6];
int x,y;
int i,j;
int code;
int cursorx = -140,cursory = -110;
driver=DETECT;
mode=0;
initgraph(&driver,&mode,"..\\bgi");
setview_ex = setview_sx + 7 * 40;
setview_ey = setview_sy + 7 * 40;
setviewport(setview_sx,setview_sy,setview_ex,setview_ey,0);
drawgame();
do{
while(bioskey(1));
key1 = bioskey(0);
key1 = key1&0xff?key1&0xff:key1>>8;
switch(key1){
case LEFT:if(cursorx < -80 && cursorx > -170){
cursorx = 20;
drawhelp();
}
else cursorx -= 80;
if(cursorx < -5 && cursorx > -80){
drawoptions();
}
if(cursorx < -80 && cursorx > -170){
drawgame();
}break;
case RIGHT:if(cursorx < 125 && cursorx > 10){
cursorx = -140;
drawgame();
}
else cursorx += 80;
if(cursorx < -5 && cursorx > -80){
drawoptions();
}
if(cursorx < 125 && cursorx >10){
drawhelp();
}break;
case ENTER : case DOWN:cursory = -90;
if(cursorx < -80 && cursory > -170)
drawnewgame();
if(cursorx <-5 && cursorx > -80)
drawbackward();
if(cursorx < 125 && cursorx > 10)
drawhowtoplay();
do{
while(bioskey(1));
key2 = bioskey(0);
key2 = key2&0xff?key2&0xff:key2>>8;
switch(key2){
case UP:if(cursorx < -80 && cursorx > -170){
if(cursory < -80 && cursory > -100){
cursory = -30;
drawexit();
}
else if(cursory < -20 && cursory > -80){
cursory -= 20;
if(cursory < -80 && cursory > -100)
drawnewgame();
if(cursory < -60 && cursory > -80)
drawload();
if(cursory < -40 && cursory > -60)
drawsave();
}
}
if(cursorx < -5 && cursorx > -80){
if(cursory < -80 && cursory > -100){
cursory = -50;
drawsize();
}
else if(cursory < -40 && cursory > -80){
cursory -= 20;
if(cursory < -80 && cursory > -100)
drawbackward();
if(cursory < -60 && cursory > -80)
drawcolor();
}
}
if(cursorx < 125 && cursorx > 10){
if(cursory < -80 && cursory > -100){
cursory = -70;
drawshortcutkey();
}
else if(cursory < -60 && cursory > -80){
cursory -= 20;
if(cursory < -80 && cursory > -100)
drawnewgame();
}
}break;
case DOWN:if(cursorx < -80 && cursorx > -170){
if(cursory < -20 && cursory > -40){
cursory = -90;
drawnewgame();
}
else if(cursory < -40 && cursory > -100){
cursory += 20;
if(cursory < -60 && cursory > -80)
drawload();
if(cursory < -40 && cursory > -60)
drawsave();
if(cursory < -20 && cursory > -40)
drawexit();
}
}
if(cursorx < -5 && cursorx > -80){
if(cursory < -40 && cursory > -60){
cursory = -90;
drawbackward();
}
else if(cursory < -60 && cursory > -100){
cursory += 20;
if(cursory < -60 && cursory > -80)
drawcolor();
if(cursory < -40 && cursory > -60)
drawsize();
}
}
if(cursorx < 125 && cursorx > 10){
if(cursory < -60 && cursory > -80){
cursory = -90;
drawhowtoplay();
}
else if(cursory < -80 && cursory > -100){
cursory += 20;
if(cursory < -60 && cursory > -80)
drawshortcutkey();
}
}break;
case LEFT:clearsubset();
cursory = -90;
if(cursorx < -80 && cursorx > -170){
cursorx = 20;
drawhelp();
drawhowtoplay();
}
else cursorx -= 80;
if(cursorx < -5 && cursorx > -80){
drawoptions();
drawbackward();
}
if(cursorx < -80 && cursorx > -170){
drawgame();
drawnewgame();
}break;
case RIGHT:clearsubset();
cursory = -90;
if(cursorx < 125 && cursorx > 10){
cursorx = -140;
drawgame();
drawnewgame();
}
else cursorx += 80;
if(cursorx < -5 && cursorx > -80){
drawoptions();
drawbackward();
}
if(cursorx < 125 && cursorx >10){
drawhelp();
drawhowtoplay();
}break;
default :;
}
}while(key2 != ESC && key2 != ENTER);
clearsubset();
break;
default :;
}
}while(key1 != ESC && key2 != ENTER);
if(cursorx < -80 && cursorx > -170){
if(cursory < -80 && cursory > -100)
{
if(a==1&&c==3){
for (x=0;x<=5;x++){
for(y=0;y<=5;y++){
b[x][y]=0; } }
small_put(b,3); }
if(a==1&&c==4){
for (x=0;x<=5;x++){
for(y=0;y<=5;y++){
b[x][y]=0; } }
small_put(b,4); }
if(a==2&&c==3){
for (x=0;x<=5;x++){
for(y=0;y<=5;y++){
b[x][y]=0; } }
small_put1(b,3); }
if(a==2&&c==4){
for (x=0;x<=5;x++){
for(y=0;y<=5;y++){
b[x][y]=0; } }
small_put1(b,4); }
}
if(cursory < -60 && cursory > -80)
{
FILE *fp;
if((fp=fopen("c:\\small_hehe.txt","r"))==NULL)
{exit(0);}
for(i=0;i<6;i++){
for(j=0;j<6;j++){
fscanf(fp,"%5d",&h[i][j]);}}
fclose(fp);
small_put(h,c);
}
if(cursory < -40 && cursory > -60)
{save();
code=specialkey();
small_main();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -