admin管理员组文章数量:1621657
#include <stdio.h>
#include <conio.h>
#include <Windows.h>
#include <malloc.h>
#define up 'w'
#define down 's'
#define left 'a'
#define right 'd'
#define fall 'p'
#define exitgame 'q'
#define replay 'y'
#define nPlayer 3
struct stuPos
{
int x;
int y;
};
struct stuBoard
{
stuPos pos; //position
int flag; //player id, initalize is 0
};
struct stuChesBoard
{
stuBoard **pBoard;
int w;
int h;
};
struct stuPlayer
{
int id;
char* chess;
stuPos pos;
};
void moveCursor(int x, int y)
{
COORD c;
c.X = 2 * x;
c.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
int playerMove(stuChesBoard *pChessBoard,stuPlayer *pPlayer,int x, int y,char flag)
{
int iPlace = 0;
if (pChessBoard->pBoard[x][y].pos.x == x
&& pChessBoard->pBoard[x][y].pos.y == y
)
{
if(fall == flag && pChessBoard->pBoard[x][y].flag == 0)
{
printf(pPlayer->chess);
pChessBoard->pBoard[x][y].flag = pPlayer->id;
iPlace = 1;
}
moveCursor(x,y);
pPlayer->pos.x = x;
pPlayer->pos.y = y;
}
return iPlace;
}
bool check(stuChesBoard *pChessBoard,int x, int y)
{
stuBoard **board = pChessBoard->pBoard;
int id = board[x][y].flag; //get id of player
版权声明:本文标题:c语言多人五子棋 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728851406a1176719.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论