-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhorse.cpp
More file actions
35 lines (30 loc) · 821 Bytes
/
horse.cpp
File metadata and controls
35 lines (30 loc) · 821 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
#include "horse.h"
horse::horse() {
onCreate();
}
horse::horse(int x, int y, int Id) {
Point p = {x,y};
onCreate();
setLocation(p);
playerId = Id; // set to which player it belongs......
}
void horse::onCreate() {
width = boxColSize;
height = boxRowSize;
sprite = new char*[height];
for(int i=0;i<height;i++)
sprite[i] = new char[width];
// create sprite for pawn............
strncpy(sprite[0], "|-------|", width);
strncpy(sprite[1], "| |", width);
strncpy(sprite[2], "| Horse |", width);
strncpy(sprite[3], "|-------|", width);
}
bool horse::canMove(Point to) {
int dx = abs(to.x - location.x); // x distance....
int dy = abs(to.y - location.y); // y distance....
if( (dx == 2 && dy == 1) || (dx == 1 && dy == 2) )
return true;
return false;
}
char horse::getPeiceId() { return 'h'; }