From 4ca680b2fa36a0139dd95302bda410d836d0010d Mon Sep 17 00:00:00 2001 From: peauxh9ov <1757486528@qq.com> Date: Mon, 17 Jun 2024 23:59:52 +0800 Subject: [PATCH] ADD file via upload --- Player.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Player.cpp diff --git a/Player.cpp b/Player.cpp new file mode 100644 index 0000000..f4db714 --- /dev/null +++ b/Player.cpp @@ -0,0 +1,24 @@ +#include "Player.h" + +void Player::init(Chess* chess) +{ + this->chess = chess; +} + +void Player::go() +{ + MOUSEMSG msg; + ChessPos pos; + while (1) + { + //获取鼠标点击信息 + msg = GetMouseMsg(); + + //判断落子是否有效,以及实现落子 + if (msg.uMsg == WM_LBUTTONDOWN && chess->clickBoard(msg.x, msg.y, &pos)) + break; + } + + //落子 + chess->ChessMove(&pos, CHESS_BLACK); +}