-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPiece.cpp
More file actions
55 lines (49 loc) · 1003 Bytes
/
Piece.cpp
File metadata and controls
55 lines (49 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "Piece.h"
CPiece::CPiece(ePiece aPiece)
:x(0)
,y(0)
,flagLive(false)
,piece(aPiece)
,color(WHITE)
{
}
CPiece::CPiece(int aPosX, int aPosY, eColor aColor, ePiece aPiece)
:x(aPosX / sizeCell)
,y(aPosY / sizeCell)
,flagLive(false)
,piece(aPiece)
,color(aColor)
{
}
CPiece::~CPiece(void)
{
}
void CPiece::resetPositionPiece(int aPosX, int aPosY)
{
if(aPosX < 50 || aPosY < 50 || aPosX > 450 || aPosY > 450)
return;
x = aPosX / sizeCell;
y = aPosY / sizeCell;
};
void CPiece::setFlagLive(bool aLive)
{
flagLive = aLive;
};
void CPiece::setColor(eColor aColor)
{
color =aColor;
};
void CPiece::setPiece(int aI, int aJ, eColor aColor)
{
x = aI;
y = aJ;
color = aColor;
}
eMove CPiece::move(int aPosX, int aPosY, vector< vector<sCell> >* aBoard)
{
int tempX = aPosX / sizeCell;
int tempY = aPosY / sizeCell;
if (tempX == x && tempY == y)
return ILLEGAL;
return _move(tempX, tempY, aBoard);
}