⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fyrad.c

📁 模仿FYRAD32编写的四子棋游戏
💻 C
📖 第 1 页 / 共 4 页
字号:
#include <stdio.h>
#include <stdlib.h>
#include <bios.h>
#include <conio.h>
#include <graphics.h>
#define ENTER 13
#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77
#define ESC 27



void Draw(void);
int specialkey();
int search(int a[8][8],int);
void put(int a[8][8],int);
void put1(int a[8][8],int);
int panduan(int a[11][14],int,int);
int panduan1(int a[11][14],int,int);
int aisearch(int a[8][8]);
int judge(int b[8][8],int,int);
int judge1(int b[8][8],int,int);
void winregister(int);
int menu(int,int);
void flash(int,int,int);
void flashcolor(int,int,int);
void help();
void shortkey();
int lowaisearch(void);
void save();
void change();
void newpicture();


void small_Draw(void);
int small_search(int a[6][6],int);
void small_put(int a[6][6],int);
void small_put1(int a[6][6],int);
int small_panduan(int a[9][12],int,int);
int small_panduan1(int a[9][12],int,int);
int aismall_search(int a[6][6]);
int small_judge(int b[6][6],int,int);
int small_judge1(int b[6][6],int,int);
int small_menu(int,int);
int lowaismall_search(void);
void small_main();

void drawgame()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-170,-120,639,-100);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-160,-120,-120,-100);
   setcolor(RED);
   moveto(-155,-115);
   outtext("Game");
   moveto(-80,-115);
   outtext("Options");
   moveto(15,-115);
   outtext("Help");
}

void drawnewgame()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-160,-100,-80,-15);
   setcolor(BLACK);
   rectangle(-157,-97,-83,-18);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-152,-92,-88,-80);
   setcolor(RED);
   moveto(-150,-90);
   outtext("New Game");
   moveto(-150,-70);
   outtext("Load");
   moveto(-150,-50);
   outtext("Save");
   moveto(-150,-30);
   outtext("Exit");
}

void drawload()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-160,-100,-80,-15);
   setcolor(BLACK);
   rectangle(-157,-97,-83,-18);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-152,-72,-88,-60);
   setcolor(RED);
   moveto(-150,-90);
   outtext("New Game");
   moveto(-150,-70);
   outtext("Load");
   moveto(-150,-50);
   outtext("Save");
   moveto(-150,-30);
   outtext("Exit");
}

void drawsave()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-160,-100,-80,-15);
   setcolor(BLACK);
   rectangle(-157,-97,-83,-18);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-152,-52,-88,-40);
   setcolor(RED);
   moveto(-150,-90);
   outtext("New Game");
   moveto(-150,-70);
   outtext("Load");
   moveto(-150,-50);
   outtext("Save");
   moveto(-150,-30);
   outtext("Exit");
}

void drawexit()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-160,-100,-80,-15);
   setcolor(BLACK);
   rectangle(-157,-97,-83,-18);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-152,-32,-88,-20);
   setcolor(RED);
   moveto(-150,-90);
   outtext("New Game");
   moveto(-150,-70);
   outtext("Load");
   moveto(-150,-50);
   outtext("Save");
   moveto(-150,-30);
   outtext("Exit");
}

void drawoptions()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-170,-120,639,-100);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-85,-120,-20,-100);
   setcolor(RED);
   moveto(-155,-115);
   outtext("Game");
   moveto(-80,-115);
   outtext("Options");
   moveto(15,-115);
   outtext("Help");
}

void drawbackward()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-85,-100,-5,-35);
   setcolor(BLACK);
   rectangle(-82,-97,-8,-38);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-77,-92,-13,-80);
   setcolor(RED);
   moveto(-75,-90);
   outtext("Size");
   moveto(-75,-70);
   outtext("Color");
   moveto(-75,-50);
   outtext("Level");
}

void drawcolor()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-85,-100,-5,-35);
   setcolor(BLACK);
   rectangle(-82,-97,-8,-38);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-77,-72,-13,-60);
   setcolor(RED);
   moveto(-75,-90);
   outtext("Size");
   moveto(-75,-70);
   outtext("Color");
   moveto(-75,-50);
   outtext("Level");
}

void drawsize()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-85,-100,-5,-35);
   setcolor(BLACK);
   rectangle(-82,-97,-8,-38);
   setfillstyle(SOLID_FILL,GREEN);
   bar(-77,-52,-13,-40);
   setcolor(RED);
   moveto(-75,-90);
   outtext("Size");
   moveto(-75,-70);
   outtext("Color");
   moveto(-75,-50);
   outtext("Level");
}

void drawhelp()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(-170,-120,639,-100);
   setfillstyle(SOLID_FILL,GREEN);
   bar(10,-120,50,-100);
   setcolor(RED);
   moveto(-155,-115);
   outtext("Game");
   moveto(-80,-115);
   outtext("Options");
   moveto(15,-115);
   outtext("Help");
}

void drawhowtoplay()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(10,-100,125,-55);
   setcolor(BLACK);
   rectangle(13,-97,122,-57);
   setfillstyle(SOLID_FILL,GREEN);
   bar(18,-92,117,-80);
   setcolor(RED);
   moveto(20,-90);
   outtext("Introduction");
   moveto(20,-70);
   outtext("    Keys    ");
}

void drawshortcutkey()
{
   setfillstyle(SOLID_FILL,BLUE);
   bar(10,-100,125,-55);
   setcolor(BLACK);
   rectangle(13,-97,122,-57);
   setfillstyle(SOLID_FILL,GREEN);
   bar(18,-72,117,-60);
   setcolor(RED);
   moveto(20,-90);
   outtext("Introduction");
   moveto(20,-70);
   outtext("    Keys    ");
}

void clearmain()
{
   setfillstyle(SOLID_FILL,BLACK);
   bar(-170,-120,639,-100);
}

void clearsubset()
{
   setfillstyle(SOLID_FILL,BLACK);
   bar(-170,-100,639,-10);
}


void main(){
  int i=1;
  int j=3;
  int k;
  int driver,mode;
  static int o=1;

  driver=DETECT;
   mode=0;
   initgraph(&driver,&mode,"..\\bgi");
 if(o<=1){
   newpicture();}
  o++;
   k=menu(i,j);

  do{
      if(k==1||k==2){k=menu(k,j);}
      if(k==3||k==4){k=menu(i,k);}
      
    }while(k==1||k==2||k==3||k==4);
  }


int menu(int a, int c)
{
   int driver,mode;
   int setview_sx = 170,setview_sy = 120,setview_ex,setview_ey;
   int key1,key2;
   int h[8][8];
   int b[8][8];
   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<=7;x++){
	          for(y=0;y<=7;y++){
	           b[x][y]=0;   }  }
            put(b,3);  }

        if(a==1&&c==4){
                 for (x=0;x<=7;x++){
	          for(y=0;y<=7;y++){
	           b[x][y]=0;   }  }
            put(b,4);  }

        if(a==2&&c==3){
                 for (x=0;x<=7;x++){
	          for(y=0;y<=7;y++){
	           b[x][y]=0;   }  }
            put1(b,3);  }

        if(a==2&&c==4){
                 for (x=0;x<=7;x++){
	          for(y=0;y<=7;y++){
	           b[x][y]=0;   }  }
            put1(b,4);  }
       }
      if(cursory < -60 && cursory > -80)
         {
           FILE *fp;

           if((fp=fopen("c:\\hehe.txt","r"))==NULL)
                     {exit(0);}

           for(i=0;i<8;i++){
              for(j=0;j<8;j++){
                 fscanf(fp,"%5d",&h[i][j]);}}

                fclose(fp);
                put(h,c);
           }
      if(cursory < -40 && cursory > -60)
        {save();
        code=specialkey();
        main();}
      if(cursory < -20 && cursory > -40)
         exit(0);
   }
   if(cursorx < -5 && cursorx > -80){
      if(cursory < -80 && cursory > -100)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -