-
Notifications
You must be signed in to change notification settings - Fork 1
/
KeyboardControl.cpp
75 lines (62 loc) · 1.65 KB
/
KeyboardControl.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "KeyboardControl.h"
extern char debug[1024];
KeyboardControl::KeyboardControl(void)
{
}
KeyboardControl::~KeyboardControl(void)
{
}
KeyboardControl::KeyboardControl(ActorStateMachine * character, OBJECTid camera):GameControl(character,camera){
}
/*
KeyboardControl::KeyboardControl(ACTORid character, OBJECTid camera):GameControl(character, camera){
}
*/
int KeyboardControl::DirControl(){
if (this->mainChar->CanBeControl() == FALSE){
return -1;
}
int key;
if (FyCheckHotKeyStatus(FY_W)){
key = MOVE_FORWARD;
}else if (FyCheckHotKeyStatus(FY_A)){
key = MOVE_LEFT;
}else if (FyCheckHotKeyStatus(FY_S)){
key = MOVE_BACK;
}else if (FyCheckHotKeyStatus(FY_D)){
key = MOVE_RIGHT;
}
this->GenerateTargetDir(key);
if (this->isOnTargetDir()){
//sprintf(debug ,"in move\n");
this->CharacterMoveForward(key);
this->CamPointToActor();
}else{
int ret = this->TurnToTargetDir();
//sprintf(debug ,"in turning: ret=%d\n", ret);
}
return 0;
}
int KeyboardControl::Command(){//the return value doesn't represent anything.
/*
if (FyCheckHotKeyStatus(FY_W) || FyCheckHotKeyStatus(FY_A)
|| FyCheckHotKeyStatus(FY_S) || FyCheckHotKeyStatus(FY_D)){
this->DirControl();
}else if(FyCheckHotKeyStatus(FY_J)) {
this->CharacterNormalAttack();
}else{
this->CharacterSetIdle();
//sprintf(debug ,"in else condition\n");
}
*/
if (FyCheckHotKeyStatus(FY_W) || FyCheckHotKeyStatus(FY_A)
|| FyCheckHotKeyStatus(FY_S) || FyCheckHotKeyStatus(FY_D)){
this->DirControl();
}else if (FyCheckHotKeyStatus(FY_SPACE)){
this->mainChar->CharacterSetGuard();
}else{
//this->CharacterSetIdle();
this->mainChar->CharacterSetIdle();
}
return 0;
}