Chess.zip
大小:31.38MB
价格:33积分
下载量:0
评分:
5.0
上传者:qq_55668468
更新日期:2025-09-22

C++与easyx实现双人象棋

资源文件列表(大概)

文件名
大小
Chess/.vs/
-
Chess/.vs/Chess/
-
Chess/.vs/Chess/FileContentIndex/
-
Chess/.vs/Chess/FileContentIndex/1456be53-20b3-4e93-9d1f-600bbad10565.vsidx
10.11KB
Chess/.vs/Chess/FileContentIndex/645dc446-f26d-448a-966a-dae8fd6ce198.vsidx
7.63KB
Chess/.vs/Chess/v17/
-
Chess/.vs/Chess/v17/.suo
26KB
Chess/.vs/Chess/v17/Browse.VC.db
37.6MB
Chess/.vs/Chess/v17/DocumentLayout.json
1.42KB
Chess/.vs/Chess/v17/ipch/
-
Chess/.vs/Chess/v17/ipch/AutoPCH/
-
Chess/.vs/Chess/v17/ipch/AutoPCH/a82cb7300c4490e6/
-
Chess/.vs/Chess/v17/ipch/AutoPCH/a82cb7300c4490e6/FILENAME.ipch
81.06MB
Chess/.vs/Chess/v17/Solution.VC.db
428KB
Chess/Chess.sln
1.4KB
Chess/Chess/
-
Chess/Chess/Chess.vcxproj
6.47KB
Chess/Chess/Chess.vcxproj.filters
970B
Chess/Chess/Chess.vcxproj.user
168B
Chess/Chess/FileName.cpp
11.83KB
Chess/Chess/x64/
-
Chess/Chess/x64/Debug/
-
Chess/Chess/x64/Debug/Chess.exe.recipe
300B
Chess/Chess/x64/Debug/Chess.ilk
3.13MB
Chess/Chess/x64/Debug/Chess.log
81B
Chess/Chess/x64/Debug/Chess.tlog/
-
Chess/Chess/x64/Debug/Chess.tlog/Chess.lastbuildstate
167B
Chess/Chess/x64/Debug/Chess.tlog/CL.command.1.tlog
722B
Chess/Chess/x64/Debug/Chess.tlog/Cl.items.tlog
125B
Chess/Chess/x64/Debug/Chess.tlog/CL.read.1.tlog
33.39KB
Chess/Chess/x64/Debug/Chess.tlog/CL.write.1.tlog
516B
Chess/Chess/x64/Debug/Chess.tlog/link.command.1.tlog
1.23KB
Chess/Chess/x64/Debug/Chess.tlog/link.read.1.tlog
2.9KB
Chess/Chess/x64/Debug/Chess.tlog/link.secondary.1.tlog
134B
Chess/Chess/x64/Debug/Chess.tlog/link.write.1.tlog
376B
Chess/Chess/x64/Debug/FileName.obj
117.93KB
Chess/Chess/x64/Debug/vc143.idb
355KB
Chess/Chess/x64/Debug/vc143.pdb
468KB
Chess/x64/
-
Chess/x64/Debug/
-
Chess/x64/Debug/Chess.exe
153.5KB
Chess/x64/Debug/Chess.pdb
5.85MB

资源内容介绍

C++与easyx实现双人象棋
#include<iostream>#include<cmath>#include<graphics.h>#include<string>using namespace std;int operate = 0, operatex, operatey, signx, signy;bool judge_red_white=0;//设置逻辑棋盘int ChessBoard[12][11] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,3,4,5,4,3,2,1,-1,-1,0,0,0,0,0,0,0,0,0,-1,-1,0,6,0,0,0,0,0,6,0,-1,-1,7,0,7,0,7,0,7,0,7,-1,-1,0,0,0,0,0,0,0,0,0,-1,-1,0,0,0,0,0,0,0,0,0,-1,-1,8,0,8,0,8,0,8,0,8,-1,-1,0,9,0,0,0,0,0,9,0,-1,-1,0,0,0,0,0,0,0,0,0,-1,-1,10,11,12,13,14,13,12,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,};void DrawForesign(int x, int y, bool a, bool b)//绘制准星线条{if (a == 1) {line(x - 5, y - 5, x - 5, y - 25);line(x - 5, y - 5, x - 25, y - 5);line(x - 5, y + 5, x - 5, y + 25);line(x - 5, y + 5, x - 25, y + 5);}if (b == 1) {line(x + 5, y - 5, x + 5, y - 25);line(x + 5, y - 5, x + 25, y - 5);line(x + 5, y + 5, x + 5, y + 25);line(x + 5, y + 5, x + 25, y + 5);}}static void DrawChessBoard()//绘制棋盘{setcolor(RGB(255, 102, 102));for (int i = 45; i <= 855; i += 90) {//横线绘制line(45, i, 765, i);}for (int i = 45; i <= 765; i += 90) {//竖线绘制if (i == 45 || i == 765) {line(i, 45, i, 855);}else {line(i, 45, i, 405);line(i, 495, i, 855);}}//大边框绘制line(42, 42, 42, 858);line(42, 858, 768, 858);line(768, 858, 768, 42);line(768, 42, 42, 42);//绘制九宫line(315, 45, 495, 225);line(495, 45, 315, 225);line(315, 675, 495, 855);line(495, 675, 315, 855);//绘制兵准星for (int i = 0; i <= 8; i += 2) {if (i == 0) {DrawForesign(45 + i * 90, 315, 0, 1);DrawForesign(45 + i * 90, 585, 0, 1);}else if (i == 8) {DrawForesign(45 + i * 90, 315, 1, 0);DrawForesign(45 + i * 90, 585, 1, 0);}else {DrawForesign(45 + i * 90, 315, 1, 1);DrawForesign(45 + i * 90, 585, 1, 1);}}//绘制炮准星DrawForesign(135, 225, 1, 1);DrawForesign(675, 225, 1, 1);DrawForesign(135, 675, 1, 1);DrawForesign(675, 675, 1, 1);}void DrawChessman(int x, int y, char *a,bool object) //绘制单个棋子{if (object) {setcolor(WHITE);setfillcolor(BLACK);fillcircle(x, y, 34);fillcircle(x, y, 28);setcolor(RGB(255,102,102));settextstyle(30, 23, "宋体");outtextxy(x - 23, y - 14, a);}else {setcolor(WHITE);setfillcolor(BLACK);fillcircle(x, y, 34);fillcircle(x, y, 28);settextstyle(30, 23, "宋体");outtextxy(x - 23, y - 14, a);}}static void DrawALLChessman() //绘制所有棋子{for (int i = 1; i <= 10; i++) {for (int j = 1; j <= 9; j++) {if (ChessBoard[i][j] == 1) {char ChessArr[] = "车";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 0);}if (ChessBoard[i][j] == 2) {char ChessArr[] = "马";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 0);}if (ChessBoard[i][j] == 3) {char ChessArr[] = "象";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 0);}if (ChessBoard[i][j] == 4) {char ChessArr[] = "士";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 0);}if (ChessBoard[i][j] == 5) {char ChessArr[] = "将";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 0);}if (ChessBoard[i][j] == 6) {char ChessArr[] = "炮";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 0);}if (ChessBoard[i][j] == 7) {char ChessArr[] = "卒";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 0);}if (ChessBoard[i][j] == 8) {char ChessArr[] = "兵";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 1);}if (ChessBoard[i][j] == 9) {char ChessArr[] = "炮";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 1);}if (ChessBoard[i][j] == 10) {char ChessArr[] = "车";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 1);}if (ChessBoard[i][j] == 11) {char ChessArr[] = "马";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 1);}if (ChessBoard[i][j] == 12) {char ChessArr[] = "相";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 1);}if (ChessBoard[i][j] == 13) {char ChessArr[] = "士";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 1);}if (ChessBoard[i][j] == 14) {char ChessArr[] = "帅";DrawChessman(j * 90 - 45, i * 90 - 45, ChessArr, 1);}}}}bool JudgeGuideline(int x1, int y1, int x2, int y2) //判断棋子下法是否正确{//判断不能吃自己的子if (ChessBoard[x2][y2] > 0) {if (ChessBoard[x2][y2] < 8 && ChessBoard[x1][y1] < 8)return 0;if (ChessBoard[x2][y2] > 7 && ChessBoard[x1][y1] > 7)return 0;}//车的走法if (ChessBoard[x1][y1] == 1||ChessBoard[x1][y1]==10) {if (x1 == x2 && y1 != y2) {for (int i = min(y1, y2)+1; i < max(y1, y2); i++) {if (ChessBoard[x1][i] > 0)return 0;}return 1;}else if (x1 != x2 && y1 == y2) {for (int i = min(x1, x2)+1; i < max(x1, x2); i++) {if (ChessBoard[i][y1] > 0)return 0;}return 1;}else {return 0;}}//马的走法if (ChessBoard[x1][y1]==2||ChessBoard[x1][y1]==11) {if (x1 - x2 == 2 && (y1 - y2 == 1 || y1 - y2 == -1)) {if (ChessBoard[x1 - 1][y1] > 0)return 0;else return 1;}else if (x2 - x1 == 2 && (y1 - y2 == 1 || y1 - y2 == -1)) {if (ChessBoard[x1 + 1][y1] > 0)return 0;else return 1;}else if (y2 - y1 == 2 && (x1 - x2 == 1 || x1 - x2 == -1)) {if (ChessBoard[x1][y1 + 1] > 0)return 0;else return 1;}else if (y2 - y1 == -2 && (x1 - x2 == 1 || x1 - x2 == -1)) {if (ChessBoard[x1][y1 - 1] > 0)return 0;else return 1;}else {return 0;}}//炮的走法if (ChessBoard[x1][y1] == 6 || ChessBoard[x1][y1] == 9) {if (ChessBoard[x2][y2] == 0) {if (x1 == x2 && y1 != y2) {for (int i = min(y1, y2)+1; i < max(y1, y2); i++) {if (ChessBoard[x1][i] > 0)return 0;}return 1;}else if (x1 != x2 && y1 == y2) {for (int i = min(x1, x2)+1; i < max(x1, x2); i++) {if (ChessBoard[i][y1] > 0)return 0;}return 1;}else {return 0;}}else {if (x1 == x2 && y1 != y2) {int temp = 0;for (int i = min(y1, y2) + 1; i < max(y1, y2); i++) {if (ChessBoard[x1][i] > 0)temp++;}if (temp == 1)return 1;else return 0;}else if(x1 != x2 && y1 == y2){int temp = 0;for (int i = min(x1, x2) + 1; i < max(x1, x2); i++) {if (ChessBoard[i][y1] > 0)temp++;}if (temp == 1)return 1;else return 0;}else {return 0;}}}//卒的走法if (ChessBoard[x1][y1] == 7) {if (x1 < 6) {if (y1 == y2 && x2 - x1 == 1)return 1;else return 0;}else {if (x1 == x2 && (y1 - y2 == 1 || y2 - y1 == 1))return 1;else if (x2 - x1 == 1 && y1 == y2)return 1;else return 0;}}//兵的走法if (ChessBoard[x1][y1] == 8) {if (x1 > 5) {if (y1 == y2 && x2 - x1 == -1)return 1;else return 0;}else {if (x1 == x2 && (y1 - y2 == 1 || y2 - y1 == 1))return 1;else if (x2 - x1 == -1 && y1 == y2)return 1;else return 0;}}//象的走法if (ChessBoard[x1][y1] == 3) {if (x2 < 6) {if ((x1 - x2 == 2 || x2 - x1 == 2) && (y1 - y2 == 2 || y2 - y1 == 2)) {if (ChessBoard[(x1 + x2) / 2][(y1 + y2) / 2] == 0)return 1;else return 0;}else return 0;}else return 0;}//相的走法if (ChessBoard[x1][y1] == 12) {if (x2 > 5) {if ((x1 - x2 == 2 || x2 - x1 == 2) && (y1 - y2 == 2 || y2 - y1 == 2)) {if (ChessBoard[(x1 + x2) / 2][(y1 + y2) / 2] == 0)return 1;else return 0;}else return 0;}else return 0;}//黑士走法if (ChessBoard[x1][y1] == 4) {if ((x2 >= 1 && x2 <= 3) && (y2 <= 6 && y2 >= 4)) {if ((x2 - x1 == 1 || x1 - x2 == 1) && (y1 - y2 == 1 || y2 - y1 == 1)) {return 1;}

用户评论 (0)

发表评论

captcha