C语言写连连看的疑问解决思路

C语言写连连看的疑问
[code=C/C++][/code]#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include <math.h>
#include <dos.h>
#include <bios.h>
#include <string.h>

#define true 1
#define false 0

typedef struct cell
{
  char x;
  char y;
} CELL;

int BkGndColor=BLACK;
int BorderColor=LIGHTGRAY;
int LineColor=LIGHTBLUE;/* 消除一对方块时时候的连线颜色 */
/* Pb - ProgressBar */
int PbColor=LIGHTGREEN;
int PbY=4;
int PbHeight=4;
int PbValue; /* 进度条百分比,初始值为100.*/
long StartTime; /* 开始时间的秒数,只统计分钟,秒 */
long TotalTime; /* 游戏总共的最大秒数!,*/

int m,n;
unsigned char Board[20][20][2];
int CellSize=30;
int BoardX=20;
int BoardY=60;
int CellNumX;/*列数*/
int CellNumY; /*行数*/
int m,n;
int CellColor=WHITE;
int SelColor=BLUE; /* selCell边界颜色 */
int CurColor=YELLOW; /* curCell边界颜色 */
int EraColor=CYAN; /* 用于擦除cell的颜色!*/
int PairsCount; /* 屏幕中有多少对 */

CELL selCell,curCell;/*缓存前一个被选中的位置以及当前所处位置!*/

enum KEYCODES
{
  K_ESC =0x011b,
  K_UP =0x4800,
  K_LEFT =0x4b00,
  K_DOWN =0x5000,
  K_RIGHT =0x4d00,
  K_SPACE =0x3920,
  K_P =0x1970,
  K_RETURN =0x1c0d,
};



/*函数列表*/
void attention();
void InitGame(char *bgiPath);
void PlayGame();
void QuitGame();
void InitProgressBar();
void UpdateProgressBar(int percent);
void DrawCell(int x,int y,int color);
void EraseCell(int x,int y);
void DrawBorderRect(CELL *c,int color);
void DrawGameOver(char* info);
int GetKeyCode();
int FindPath(CELL *c1,CELL *c2);
void DrawPath(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,int color);

/* 函数实现 */

void attention()
{
  int i,j;
  window(1,1,100,50);
  textbackground(LIGHTBLUE);
  textcolor(YELLOW);
  clrscr();
  gotoxy(25,4);
  printf("Game Start:(1)");
  gotoxy(25,10);
  printf("Game Over:(0)");
  gotoxy(25,16);
  printf("Please choose,press enter sure");
  gotoxy(25,20);
  scanf("%d",&i);
  if(i==1)
  {
  clrscr();
  window(1,1,100,50);
  textbackground(LIGHTBLUE);
  textcolor(YELLOW);
  gotoxy(25,10);
  printf("Game rules:");
  gotoxy(25,14);
  printf("press Left,Right,Up,Down key to move");
  gotoxy(25,18);
  printf("press ESC to quit");
  gotoxy(20,22);
  printf("Choose easy:(2) difficult:(3)");
  gotoxy(25,26);
  scanf("%d",&j);
  if(j==2)
  {
  clrscr();
  CellNumX=8;
  CellNumY=5;
  m=2;
  n=12;
   
  }
  if(j==3)
  {
  clrscr();
  CellNumX=16;
  CellNumY=9;
  m=2;
  n=38;
   
   
  }
  InitGame("");
  InitProgressBar();
  PlayGame();