|
|
|
|
#pragma once
|
|
|
|
|
#include<graphics.h>
|
|
|
|
|
#include<vector>
|
|
|
|
|
using namespace std;
|
|
|
|
|
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
struct ChessPos {
|
|
|
|
|
int row;
|
|
|
|
|
int col;
|
|
|
|
|
|
|
|
|
|
ChessPos(int r=0,int c=0):row(r),col(c){}
|
|
|
|
|
};
|
|
|
|
|
typedef enum {
|
|
|
|
|
CHESS_WHITE = -1,
|
|
|
|
|
CHESS_BLACK = 1
|
|
|
|
|
}chess_kind_t;
|
|
|
|
|
class Chess
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Chess(int gradeSize, int marginX, int marginY, float chessSize);
|
|
|
|
|
void init();//<2F><><EFBFBD>̳<EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
bool clickBoard(int x, int y, ChessPos* pos);//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>pos<6F><73>
|
|
|
|
|
void chessDown(ChessPos* pos, chess_kind_t kind);//<2F><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>ָ<EFBFBD><D6B8>λ<EFBFBD>ã<EFBFBD>pos<6F><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>kind<6E><64>
|
|
|
|
|
int getGradeSize();//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>̴<EFBFBD>С
|
|
|
|
|
int getChessData(ChessPos* pos);//<2F><>ȡָ<C8A1><D6B8>λ<EFBFBD>õ<EFBFBD><C3B5>Ǻ<EFBFBD><C7BA>廹<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>
|
|
|
|
|
int getChessData(int row,int col);
|
|
|
|
|
bool checkOver();
|
|
|
|
|
private:
|
|
|
|
|
IMAGE chessBlackImg;
|
|
|
|
|
|
|
|
|
|
IMAGE chessWhiteImg;
|
|
|
|
|
|
|
|
|
|
int gradeSize;//<2F><><EFBFBD>̴<EFBFBD>С
|
|
|
|
|
int margin_x;//<2F><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD>
|
|
|
|
|
int margin_y;//<2F><><EFBFBD>εĶ<CEB5><C4B6><EFBFBD><EFBFBD>߽<EFBFBD>
|
|
|
|
|
float chessSize;//<2F><><EFBFBD>ӵĴ<D3B5>С
|
|
|
|
|
|
|
|
|
|
//<2F>洢<EFBFBD><E6B4A2>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
vector<vector<int>> chessMap;
|
|
|
|
|
//<2F><>ʾ<EFBFBD><CABE><EFBFBD>ڸ<EFBFBD>˭<EFBFBD><CBAD><EFBFBD><EFBFBD>
|
|
|
|
|
bool playerFlag;//true:<3A>ú<EFBFBD><C3BA><EFBFBD><EFBFBD>ߣ<EFBFBD>false:<3A>ð<EFBFBD><C3B0><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void updateGameMap(ChessPos* pos);
|
|
|
|
|
bool checkWin();//<2F><><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD>ѷ֣<D1B7><D6A3><EFBFBD><EFBFBD><EFBFBD>ture<72><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false
|
|
|
|
|
ChessPos lastPos;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
};
|
|
|
|
|
|