-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNarutoSKeySet.cpp
203 lines (194 loc) · 5.76 KB
/
NarutoSKeySet.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include "NarutoS.h"
#include "Constants.h"
#include "Character.h"
#include "keyMap.h"
void NarutoS::handleMove() {
// 一级屏蔽s
if (currentState == CharacterState::Flash ||
currentState == CharacterState::Hit ||
currentState == CharacterState::Kick) {
return;
}
if (sf::Keyboard::isKeyPressed(key[real]["L"])) { // 冲刺
if (jumpTimes > 1 || chakra <= CHAKRA_L) { //之后补充chakra机制限制冲刺次数,同时空中只能冲刺一次
return;
}
flash();
return;
}
if (sf::Keyboard::isKeyPressed(key[real]["S"])) { // S:防御、下落、普攻3、大招3、远攻3
if (sf::Keyboard::isKeyPressed(key[real]["K"])) {
down();
}
else if (sf::Keyboard::isKeyPressed(key[real]["J"])) {
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S)
{
sj();
}
}
else if (sf::Keyboard::isKeyPressed(key[real]["I"])) {
// 大招3
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S)
{
si();
}
}
else if (sf::Keyboard::isKeyPressed(key[real]["U"])) {
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S)
{
su();
}
else if (currentState == CharacterState::SU && currentFrame > 10) { // SU打完才能触发suu
suu();
}
}
else { // 单独的S
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S)
{
s();
}
}
}
else if (sf::Keyboard::isKeyPressed(key[real]["K"])) { // 没按S 有K 则跳跃
jump();
}
else if (currentState == CharacterState::S) { // 没按S,但在防御,表明松开S
s_release(); // 不加return,可被打断
}
// W系列
if (sf::Keyboard::isKeyPressed(key[real]["W"])) {
if (sf::Keyboard::isKeyPressed(key[real]["J"])) {
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S_Release)
wj();
}
else if (sf::Keyboard::isKeyPressed(key[real]["I"])) {
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S_Release)
wi();
}
else if (sf::Keyboard::isKeyPressed(key[real]["U"])) {
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S_Release)
wu();
else if (currentState == CharacterState::WU && currentFrame > 24) { // WU24帧后才能触发WUU
wuu();
}
}
}
else { // 没按W
if (sf::Keyboard::isKeyPressed(key[real]["U"])) {
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S_Release)
u();
else if (jumpTimes <= 2 &&
(currentState == CharacterState::Jumping ||
currentState == CharacterState::Fall)) {
ku();
}
}
else if (sf::Keyboard::isKeyPressed(key[real]["I"])) {
if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::S_Release)
i();
else if (currentState == CharacterState::Jumping ||
currentState == CharacterState::Fall)
ki();
}
}
if (!sf::Keyboard::isKeyPressed(key[real]["S"]) &&
!sf::Keyboard::isKeyPressed(key[real]["W"]) &&
sf::Keyboard::isKeyPressed(key[real]["J"]) &&
(currentState == CharacterState::J1 ||
currentState == CharacterState::J2 ||
currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::Jumping ||
currentState == CharacterState::Fall)
) // 单独J
{
if (jumpTimes <= 2 &&
(currentState == CharacterState::Jumping ||
currentState == CharacterState::Fall)
) { // 空中J
kj();
}
else if (currentState == CharacterState::Stand ||
currentState == CharacterState::Running ||
currentState == CharacterState::Landed ||
currentState == CharacterState::J1 ||
currentState == CharacterState::J2) { // 限制在地面
switch (attackStage) {
case 0:
j1(); // 一段J
printf("J1\n");
break;
case 1:
if (currentFrame > 3) { // 后续加了人物就每个人物定制这个限制
j2(); // 二段J, 播放11张图片后才能按,否则忽略
printf("J2\n");
}
break;
case 2:
if (currentFrame > 4) {// 三段,等二段播了4张才能按
printf("J3\n");
j3();
}
break;
case 3:
if (currentFrame > 6) { // 四段,等三段播了6张才能触发
printf("J4\n");
j4();
}
}
}
}
// AD屏蔽
if (
currentState != CharacterState::Stand &&
currentState != CharacterState::Running &&
currentState != CharacterState::Landed &&
currentState != CharacterState::Jumping &&
currentState != CharacterState::Fall
)
return;
// AD 经常被屏蔽,放后面
if (sf::Keyboard::isKeyPressed(key[real]["A"])) {
moveLeft();
//return;
}
else if (sf::Keyboard::isKeyPressed(key[real]["D"])) {
moveRight();
//return;
}
if (!sf::Keyboard::isKeyPressed(key[real]["A"]) && !sf::Keyboard::isKeyPressed(key[real]["D"])) {
velocity.x = 0; // 停止水平移动
if (currentState == CharacterState::Running) {
currentState = CharacterState::Stand;
currentFrame = 0;
}
}
}