五连珠c语言,【C语言】五子连珠代码

//

//程序名称:五子连珠

//编译环境:Visual C++ 2010/6.0,EasyX_2011惊蛰版

//程序编写:Amanda_澜 xielan319@126.com

//最后更新:2011-12

//

//图片(游戏界面)和文件(排行榜)部分未上传

//

#include

#include

#include

#include

#include

struct CHESSINFO

{

int x;

int y;

COLORREF color;

};

struct PlayerInfo

{

char name[10];

int mark;

int n;

};

void welcome();

void Init();  //画格子

void Start(CHESSINFO chess[15][15]);  //初始化游戏界面

void DrawChess(int x, int y, COLORREF color);

//画棋子

void DrawCircle(int x, int y);  //画圈(选中棋子)

void DeleteCircle(int x, int y);  //取消选中

void CreatChess(CHESSINFO chess[15][15],int NUM);

//随机产生棋子(3种颜色各NUM个)

void PlayChess(CHESSINFO chess[15][15], MOUSEMSG m,int*mark);

//开始游戏

int JudgeMoving(CHESSINFO chess[15][15], int Y1, int X1, int

Y2, int X2); //判断两点之间是否能移动

void FlashMove(int x1, int y1, int x2, int y2);

void FlashChess(int x, int y, COLORREF color, COLORREF temp);

//消失的棋子闪动

int CheckResult(CHESSINFO chess[15][15], int X2, int Y2);

//判断移动结果是否有5个或5个以上同色棋子相连

void CreatNewChess(CHESSINFO chess[15][15], int num);

void Input_Player_Info(int mark, int n);

void FlashMove(int x1, int y1, int x2, int y2, COLORREF

color)

{

int x,y,i;

if (x1

y1==y2){

for(x=x1; x

DrawChess(x,y1,color);

Sleep(10);

DrawChess(x,y1,RGB(172,179,138));

setcolor(BLACK);

for (i=1;i<15;i++){

line(150,100+25*i,525,100+25*i);

line(150+25*i,100,150+25*i,475);

}

}

}

if (x1>x2 &&

y1==y2){

for(x=x1; x>x2; x--){

DrawChess(x,y1,color);

Sleep(10);

DrawChess(x,y1,RGB(172,179,138));

setcolor(BLACK);

for (i=1;i<15;i++){

line(150,100+25*i,525,100+25*i);

line(150+25*i,100,150+25*i,475);

}

}

}

if (x1==x2 &&

y1>y2){

for(y=y1; y>y2; y--){

DrawChess(x1,y,color);

Sleep(10);

DrawChess(x1,y,RGB(172,179,138));

setcolor(BLACK);

for (i=1;i<15;i++){

line(150,100+25*i,525,100+25*i);

line(150+25*i,100,150+25*i,475);

}

}

}

if (x1==x2 &&

y1

for(y=y1; y

DrawChess(x1,y,color);

Sleep(10);

DrawChess(x1,y,RGB(172,179,138));

setcolor(BLACK);

for (i=1;i<15;i++){

line(150,100+25*i,525,100+25*i);

line(150+25*i,100,150+25*i,475);

}

}

}

}

void FlashChess(int x, int y, COLORREF color, COLORREF

temp)

{

int i;

for(i=0;i<1;i++){

DrawChess(x,y,color);

Sleep(150);

DrawChess(x,y,temp);

Sleep(150);

}

DrawChess(x,y,color);

Sleep(150);

}

void Input_Player_Info(int mark, int n)

{

IMAGE img;

MOUSEMSG m;

PlayerInfo temp;

PlayerInfo rankinfo[10];

int i,j;

char Mark[10],N[10],I[10];

InputBox(temp.name,10,"请输入您的姓名:","游戏结束","");

temp.mark = mark;

temp.n = n;

FILE*fp;

if((fp=fopen("PlayerInfo.txt","r"))==NULL){

printf("打开排行榜文件失败!");

exit(0);

}

for(i=0;i<10;i++)

{

fscanf(fp,"%s%d%d",&rankinfo[i].name,&rankinfo[i].mark,&rankinfo[i].n);

}

fclose(fp);

for(i=0;i<10;i++)

{

if(temp.mark>=rankinfo[i].mark)

{

j=i;

break;

}

}

for(i=8;i>=j;i--)

{

rankinfo[i+1]=rankinfo[i];

}

strcpy(rankinfo[j].name,temp.name);

rankinfo[j].mark=temp.mark;

rankinfo[j].n=temp.n;

if((fp=fopen("PlayerInfo.txt","w"))==NULL)

printf("打开排行榜文件失败!");

loadimage(&img, "排行榜.jpg");

putimage(0, 0, &img);

if((fp=fopen("PlayerInfo.txt","r"))==NULL){

printf("打开排行榜文件失败!");

exit(0);

}

for(i=0;i<10;i++)

{

fscanf(fp,"%s%d%d",&rankinfo[i].name,&rankinfo[i].mark,&rankinfo[i].n);

}

for (i=0;i<10;i++){

setcolor(BLACK);

sprintf(I,"%d",i+1);

sprintf(Mark,"%d",rankinfo[i].mark);

sprintf(N,"%d",rankinfo[i].n);

outtextxy(310,180+i*20,I);

outtextxy(340,180+i*20,rankinfo[i].name);

outtextxy(390,180+i*20,Mark);

outtextxy(440,180+i*20,N);

}

while (true)

{

if (MouseHit())

m = GetMouseMsg();

switch (m.uMsg)

{

case WM_LBUTTONDOWN:

break;

default:

continue;

}

if (m.x>525 &&

m.y>425 &&

m.x<610 &&

m.y<450){

return;

}

}

fclose(fp);

return;

}

void CreatNewChess(CHESSINFO chess[15][15], int num)

{

srand( (unsigned)time( NULL ) );

int i=0,x,y,c;

while (i

{

x = rand() % 15;

y = rand() % 15;

c = rand() % 3;

if (chess[y][x].color==RGB(172,179,138) ||

chess[y][x].color==0){

if (c==0){

chess[y][x].x = 162+x*25;

chess[y][x].y = 112+y*25;

chess[y][x].color = RED;

FlashChess(chess[y][x].x, chess[y][x].y, RGB(172,179,138),

chess[y][x].color);

DrawChess(chess[y][x].x,chess[y][x].y,chess[y][x].color);

i++;

}

if (c==1){

chess[y][x].x = 162+x*25;

chess[y][x].y = 112+y*25;

chess[y][x].color = GREEN;

FlashChess(chess[y][x].x, chess[y][x].y, RGB(172,179,138),

chess[y][x].color);

DrawChess(chess[y][x].x,chess[y][x].y,chess[y][x].color);

i++;

}

if (c==2){

chess[y][x].x = 162+x*25;

chess[y][x].y = 112+y*25;

chess[y][x].color = BLUE;

FlashChess(chess[y][x].x, chess[y][x].y, RGB(172,179,138),

chess[y][x].color);

DrawChess(chess[y][x].x,chess[y][x].y,chess[y][x].color);

i++;

}

}

}

}

int CheckResult(CHESSINFO chess[15][15], int x, int y)

{

COLORREF temp;

int num1, num2, num3, num4,sum;

int a1[5]={0}, b1[5]={0},

a2[5]={0}, b2[5]={0},

a3[5]={0}, b3[5]={0},

a4[5]={0}, b4[5]={0};

sum=0,num1=0,num2=0,num3=0,num4=0;

int i;

//------纵向判断------//

for (i=1;i<5 &&

y-i>=0;i++){

if (chess[y][x].color==chess[y-i][x].color){

num1++;

a1[i] = y-i;

}

if (chess[y][x].color!=chess[y-i][x].color)

break;

}

for (i=1;i<5 &&

y+i<15;i++){

if (chess[y][x].color==chess[y+i][x].color){

num1++;

b1[i] = y+i;

}

if (chess[y][x].color!=chess[y+i][x].color)

break;

}

//------横向判断------//

for (i=1;i<5 &&

x-i>=0;i++){

if (chess[y][x].color==chess[y][x-i].color){

num2++;

a2[i] = x-i;

}

if (chess[y][x].color!=chess[y][x-i].color)

break;

}

for (i=1;i<5 &&

x+i<15;i++){

if (chess[y][x].color==chess[y][x+i].color){

num2++;

b2[i] = x+i;

}

if (chess[y][x].color!=chess[y][x+i].color)

break;

}

//------"\"斜向判断------//

for (i=1;i<5 &&

y-i>=0 &&

x-i>=0;i++){

if (chess[y][x].color==chess[y-i][x-i].color){

num3++;

a3[i] = i;

}

if (chess[y][x].color!=chess[y-i][x-i].color)

break;

}

for (i=1;i<5 &&

y+i<15 &&

x+i<15;i++){

if (chess[y][x].color==chess[y+i][x+i].color){

num3++;

b3[i] = i;

}

if (chess[y][x].color!=chess[y+i][x+i].color)

break;

}

//------"/"斜向判断------//

for (i=1;i<5 &&

y-i>=0 &&

x+i<15;i++){

if (chess[y][x].color==chess[y-i][x+i].color){

num4++;

a4[i] = i;

}

if (chess[y][x].color!=chess[y-i][x+i].color)

break;

}

for (i=1;i<5 &&

y+i<15 &&

x-i>=0;i++){

if (chess[y][x].color==chess[y+i][x-i].color){

num4++;

b4[i] = i;

}

if (chess[y][x].color!=chess[y+i][x-i].color)

break;

}

//竖着消除棋子

if (num1>3){

for (i=1;i<5;i++){

if (a1[i]!=0){

chess[a1[i]][x].x = 162+x*25;

chess[a1[i]][x].y = 112+a1[i]*25;

temp = chess[a1[i]][x].color;

chess[a1[i]][x].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[a1[i]][x].x,chess[a1[i]][x].y,chess[a1[i]][x].color,temp);

}

}

for (i=1;i<5;i++){

if (b1[i]!=0){

chess[b1[i]][x].x = 162+x*25;

chess[b1[i]][x].y = 112+b1[i]*25;

temp = chess[b1[i]][x].color;

chess[b1[i]][x].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[b1[i]][x].x,chess[b1[i]][x].y,chess[b1[i]][x].color,temp);

}

}

for (i=0;i<1;i++){

DrawChess(chess[y][x].x,chess[y][x].y,temp);

Sleep(150);

DrawChess(chess[y][x].x,chess[y][x].y,RGB(172,179,138));

Sleep(150);

}

}

//横着消除棋子

if (num2>3){

for (i=1;i<5;i++){

if (a2[i]!=0){

chess[y][a2[i]].x = 162+a2[i]*25;

chess[y][a2[i]].y = 112+y*25;

temp = chess[y][a2[i]].color;

chess[y][a2[i]].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[y][a2[i]].x,chess[y][a2[i]].y,chess[y][a2[i]].color,temp);

}

}

for (i=1;i<5;i++){

if (b2[i]!=0){

chess[y][b2[i]].x = 162+b2[i]*25;

chess[y][b2[i]].y = 112+y*25;

temp = chess[y][b2[i]].color;

chess[y][b2[i]].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[y][b2[i]].x,chess[y][b2[i]].y,chess[y][b2[i]].color,temp);

}

}

for (i=0;i<1;i++){

DrawChess(chess[y][x].x,chess[y][x].y,temp);

Sleep(150);

DrawChess(chess[y][x].x,chess[y][x].y,RGB(172,179,138));

Sleep(150);

}

}

//"\"斜着消除棋子

if (num3>3){

for (i=1;i<5;i++){

if (a3[i]!=0){

chess[y-a3[i]][x-a3[i]].x = 162+(x-a3[i])*25;

chess[y-a3[i]][x-a3[i]].y = 112+(y-a3[i])*25;

temp = chess[y-a3[i]][x-a3[i]].color;

chess[y-a3[i]][x-a3[i]].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[y-a3[i]][x-a3[i]].x,chess[y-a3[i]][x-a3[i]].y,chess[y-a3[i]][x-a3[i]].color,temp);

}

}

for (i=1;i<5;i++){

if (b3[i]!=0){

chess[y+b3[i]][x+b3[i]].x = 162+(x+b3[i])*25;

chess[y+b3[i]][x+b3[i]].y = 112+(y+b3[i])*25;

temp = chess[y+b3[i]][x+b3[i]].color;

chess[y+b3[i]][x+b3[i]].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[y+b3[i]][x+b3[i]].x,chess[y+b3[i]][x+b3[i]].y,chess[y+b3[i]][x+b3[i]].color,temp);

}

}

for (i=0;i<1;i++){

DrawChess(chess[y][x].x,chess[y][x].y,temp);

Sleep(150);

DrawChess(chess[y][x].x,chess[y][x].y,RGB(172,179,138));

Sleep(150);

}

}

//"/"斜着消除棋子

if (num4>3){

for (i=1;i<5;i++){

if (a4[i]!=0){

chess[y-a4[i]][x+a4[i]].x = 162+(x+a4[i])*25;

chess[y-a4[i]][x+a4[i]].y = 112+(y-a4[i])*25;

temp = chess[y-a4[i]][x+a4[i]].color;

chess[y-a4[i]][x+a4[i]].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[y-a4[i]][x+a4[i]].x,chess[y-a4[i]][x+a4[i]].y,chess[y-a4[i]][x+a4[i]].color,temp);

}

}

for (i=1;i<5;i++){

if (b4[i]!=0){

chess[y+b4[i]][x-b4[i]].x = 162+(x-b4[i])*25;

chess[y+b4[i]][x-b4[i]].y = 112+(y+b4[i])*25;

temp = chess[y+b4[i]][x-b4[i]].color;

chess[y+b4[i]][x-b4[i]].color = RGB(172,179,138);

chess[y][x].color = RGB(172,179,138);

FlashChess(chess[y+b4[i]][x-b4[i]].x,chess[y+b4[i]][x-b4[i]].y,chess[y+b4[i]][x-b4[i]].color,temp);

}

}

for (i=0;i<1;i++){

DrawChess(chess[y][x].x,chess[y][x].y,temp);

Sleep(150);

DrawChess(chess[y][x].x,chess[y][x].y,RGB(172,179,138));

Sleep(150);

}

}

if (num1<4)

num1 = 0;

if (num1>3)

num1++;

if (num2<4)

num2 = 0;

if (num2>3)

num2++;

if (num3<4)

num3 = 0;

if (num3>3)

num3++;

if (num4<4)

num4 = 0;

if (num4>3)

num4++;

sum = num1+num2+num3+num4;

return sum;

}

int JudgeMoving(CHESSINFO chess[15][15], int Y1, int X1, int

Y2, int X2)

{

int i;

int a=0;

if (X2==X1 &&

Y2

for (i=Y1-1;i>Y2+1;i--){

if(chess[i][X2].color==RED || chess[i][X2].color==GREEN ||

chess[i][X2].color==BLUE)

a++;

}

if (a==0)

return 1;

}

if (X2==X1 &&

Y2>Y1){  //(X2,Y2)在(X1,Y1)的下边

for (i=Y1+1;i

if(chess[i][X2].color==RED || chess[i][X2].color==GREEN ||

chess[i][X2].color==BLUE)

a++;

}

if (a==0)

return 1;

}

if (X2

Y2==Y1){  //(X2,Y2)在(X1,Y1)的左边

for (i=X1-1;i>X2-1;i--){

if(chess[Y2][i].color==RED || chess[Y2][i].color==GREEN ||

chess[Y2][i].color==BLUE)

a++;

}

if (a==0)

return 1;

}

if (X2>X1 &&

Y2==Y1){  //(X2,Y2)在(X1,Y1)的右边

for (i=X1+1;i

if(chess[Y2][i].color==RED || chess[Y2][i].color==GREEN ||

chess[Y2][i].color==BLUE)

a++;

}

if (a==0)

return 1;

}

}

void welcome()

{

cleardevice();

IMAGE img;

loadimage(&img, "欢迎界面.jpg");

putimage(0, 0, &img);

setbkmode(TRANSPARENT);

setcolor(WHITE);

setfont(16, 0, "宋体");

int c=255; // 实现闪烁的"按任意键继续"

while(!kbhit()||!MouseHit())

{

setcolor(RGB(c, 0, 0));

outtextxy(350, 450, "按键盘任意键继续");

c -= 8;

if (c < 0)

c = 255;

Sleep(20);

}

getch();

}

void PlayChess(CHESSINFO chess[15][15], MOUSEMSG m, int*mark

,int*N)

{

COLORREF temp_color;

int X1=0,Y1=0,X2=0,Y2=0;

int a=3,b=1,n=0,i,j;

char Mark[10];

*mark = 0;

*N = 0;

while(true)

{

m = GetMouseMsg();

switch(m.uMsg)

{

case WM_LBUTTONDOWN:

if (m.x<600 &&

m.x>550 &&

m.y>185 &&

m.y<210){  //如果用户点击“结束”

for (i=0;i<15;i++)

for (j=0;j<15;j++){

chess[i][j].x = 162+i*25;

chess[i][j].y = 112+j*25;

DrawChess(chess[i][j].x,chess[i][j].y,RGB(172,179,138));

}

return;

}

if (m.x<525 &&

m.x>150 &&

m.y>100 &&

m.y<475){

X1 = (m.x-150)/25; //计算当前所选中的棋子在二维数组的位置

Y1 = (m.y-100)/25;

if (chess[Y1][X1].x==0 &&

chess[Y2][X2].y==0){

continue;

}

if (chess[Y1][X1].x!=0 &&

chess[Y1][X1].y!=0){

a = 1;

DrawCircle(chess[Y1][X1].x,chess[Y1][X1].y);

temp_color = chess[Y1][X1].color; //保存当前要移动的棋子的颜色

chess[Y1][X1].color = RGB(172,179,138);

//将当前要移动的棋子设置为背景色

}

while (a<2)

{

m = GetMouseMsg();

switch(m.uMsg)

{

case WM_LBUTTONDOWN:

X2 = (m.x-150)/25;

Y2 = (m.y-100)/25;

if (chess[Y2][X2].color==0

||chess[Y2][X2].color==RGB(172,179,138)){

if(JudgeMoving(chess, Y1,X1,Y2,X2)==1){

chess[Y2][X2].x = 162+X2*25;

chess[Y2][X2].y = 112+Y2*25;

chess[Y2][X2].color = temp_color;

DrawChess(chess[Y1][X1].x,chess[Y1][X1].y,chess[Y1][X1].color);

DeleteCircle(chess[Y1][X1].x,chess[Y1][X1].y);

FlashMove(162+X1*25,112+Y1*25,162+X2*25,112+Y2*25,chess[Y2][X2].color);

DrawChess(chess[Y2][X2].x,chess[Y2][X2].y,chess[Y2][X2].color);

a++;

}

else

continue;

}

n=CheckResult(chess,X2,Y2);

if (n>4){

CreatNewChess(chess,n);

*mark = *mark+(2*n-5);

*N = *N+n;

}

setcolor(RGB(172,179,138));

setfillstyle(RGB(172,179,138));

fillcircle(570,385,20);

setcolor(BLACK);

sprintf(Mark, "%d", *mark);

outtextxy(565, 380, Mark);

break;

}

}

b++;

break;

}

default:

continue;

}

}

}

void DrawChess(int x, int y, COLORREF color)

{

setcolor(RGB(172,179,138));

setfillstyle(color);

fillcircle(x,y,8);

}

void DeleteCircle(int x, int y)

{

setcolor(RGB(172,179,138));

circle(x,y,8);

}

void DrawCircle(int x, int y)

{

setcolor(YELLOW);

circle(x,y,8);

}

void CreatChess(CHESSINFO chess[15][15], int NUM)

{

srand( (unsigned)time( NULL ) );

int i,j;

CHESSINFO a[15][15]={0}; //构造一个有序的二维数组

for (i=0;i<15;i++)

for (j=0;j<15;j++){

a[i][j].x=i;

a[i][j].y=j;

}

int b,c,d,e;

CHESSINFO temp;

for (i=0;i<15*15;i++){ //将有序二维数组打乱

b = rand() % 15;

c = rand() % 15;

d = rand() % 15;

e = rand() % 15;

temp.x = a[b][c].x;

a[b][c].x = a[d][e].x;

a[d][e].x = temp.x;

temp.y = a[b][c].y;

a[b][c].y = a[d][e].y;

a[d][e].y = temp.y;

}

int X1,Y1,X2,Y2,X3,Y3;

for (i=0;i

X1 = a[0][i].x; //选择打乱后的二维数组的第一行的值来确定棋子坐标

Y1 = a[0][i].y;

chess[Y1][X1].x = 162+X1*25;

chess[Y1][X1].y = 112+Y1*25;

chess[Y1][X1].color = BLUE;

DrawChess(chess[Y1][X1].x,chess[Y1][X1].y,chess[Y1][X1].color);

X2 = a[1][i].x; //选择打乱后的二维数组的第二行的值来确定棋子坐标

Y2 = a[1][i].y;

chess[Y2][X2].x = 162+X2*25;

chess[Y2][X2].y = 112+Y2*25;

chess[Y2][X2].color = GREEN;

DrawChess(chess[Y2][X2].x,chess[Y2][X2].y,chess[Y2][X2].color);

X3 = a[2][i].x; //选择打乱后的二维数组的第三行的值来确定棋子坐标

Y3 = a[2][i].y;

chess[Y3][X3].x = 162+X3*25;

chess[Y3][X3].y = 112+Y3*25;

chess[Y3][X3].color = RED;

DrawChess(chess[Y3][X3].x,chess[Y3][X3].y,chess[Y3][X3].color);

}

}

void Init()

{

int i;

IMAGE img;

loadimage(&img, "游戏界面.jpg");

putimage(0, 0, &img);

setcolor(BLACK);

rectangle(150,100,625,475);

line(525,100,525,475);

for (i=1;i<15;i++){ //画格子

line(150,100+25*i,525,100+25*i);

line(150+25*i,100,150+25*i,475);

}

line(525,325,625,325);

rectangle(545,110,605,145); //画按键

rectangle(545,145,605,180);

rectangle(545,180,605,215);

rectangle(545,215,605,250);

rectangle(550,115,600,140);

rectangle(550,150,600,175);

rectangle(550,185,600,210);

rectangle(550,220,600,245);

}

void Start(CHESSINFO chess[15][15])

{

IMAGE img;

MOUSEMSG m;

char num[10];

int NUM;

Init();  //画格子

while (true)

{

if (MouseHit())

m = GetMouseMsg();

switch (m.uMsg)

{

case WM_LBUTTONDOWN:

break;

default:

continue;

}

if (m.x>550 &&

m.x<600 &&

m.y>115 &&

m.y<140){  //如果用户选择的是“开始”

InputBox(num,10,"请输入初始棋子数(3的倍数,且大于等于15)","开始游戏","");

NUM=atoi(num)/3;

m = GetMouseMsg();

CreatChess(chess,NUM);

return;

}

if (m.x>550 &&

m.x<600 &&

m.y>220 &&

m.y<245){  //如果用户选择的是“排行”

PlayerInfo rankinfo[10];

FILE*fp;

char Mark[10],n[10],I[10];

loadimage(&img, "排行榜.jpg");

putimage(0, 0, &img);

if((fp=fopen("PlayerInfo.txt","r"))==NULL){

printf("打开排行榜文件失败!");

exit(0);

}

for(int i=0;i<10;i++)

{

fscanf(fp,"%s%d%d",&rankinfo[i].name,&rankinfo[i].mark,&rankinfo[i].n);

}

for (i=0;i<10;i++){

setcolor(BLACK);

sprintf(I,"%d",i+1);

sprintf(Mark,"%d",rankinfo[i].mark);

sprintf(n,"%d",rankinfo[i].n);

outtextxy(310,180+i*20,I);

outtextxy(340,180+i*20,rankinfo[i].name);

outtextxy(390,180+i*20,Mark);

outtextxy(440,180+i*20,n);

}

while (true)

{

if (MouseHit())

m = GetMouseMsg();

switch (m.uMsg)

{

case WM_LBUTTONDOWN:

break;

default:

continue;

}

if (m.x>525 &&

m.y>425 &&

m.x<610 &&

m.y<450){

Start(chess);

return;

}

}

}

if (m.x>550 &&

m.x<600 &&

m.y>150 &&

m.y<175){  //如果用户选择的是“帮助”

loadimage(&img, "游戏规则.jpg");

putimage(0, 0, &img);

while (true)

{

if (MouseHit())

m = GetMouseMsg();

switch (m.uMsg)

{

case WM_LBUTTONDOWN:

break;

default:

continue;

}

if (m.x>620 &&

m.x<730 &&

m.y>500 &&

m.y<560){  //单机界面“返回”二字返回游戏界面

Start(chess);

return;

}

}

}

}

}

void main()

{

initgraph(798, 656);

CHESSINFO Chess[15][15]={0};

int Mark,N;

welcome();

while(true){

Start(Chess);

MOUSEMSG m = GetMouseMsg();

PlayChess(Chess,m,&Mark,&N);

Input_Player_Info(Mark,N);

}

getch();

closegraph();

}

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值