-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHuman.cpp
38 lines (31 loc) · 807 Bytes
/
Human.cpp
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
#include "Player.cpp"
#ifndef HUMAN
#define HUMAN
class Human:public Player{
public:
View* view;
Human(View*);
void getNextStep(Board*, int, int*, int*);
private:
};
/********** Public **********/
Human::Human(View* view) : view(view){
}
void Human::getNextStep(Board* board, int playerNum, int* row, int* column){
int ch;
do{
ch=getch();
if (ch == KEY_UP){
view->moveCursorUp(board);
}else if (ch == KEY_DOWN){
view->moveCursorDown(board);
}else if (ch == KEY_LEFT){
view->moveCursorLeft(board);
}else if (ch == KEY_RIGHT){
view->moveCursorRight(board);
}
}while(ch != '\n');
view->getCursorPosition(row, column);
}
/********** Private **********/
#endif