-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage.cpp
361 lines (290 loc) · 10.6 KB
/
stage.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
//
// Created by Allen on 2/29/2020.
//
#include "stage.h"
#include "metadata.h"
#include "entities.h"
#include "UART.h"
// if damage == 0, corner is left. else, it's right corner
const Hurtbox FD_leftCorner = Hurtbox(true, 38, 103,
SHAPE_CIRCLE, 8,
1, 0,0, 0, 0);
const Hurtbox FD_rightCorner = Hurtbox(
true, 275, 103, SHAPE_CIRCLE,8,
1, 1,1, 0, 0);
const Hurtbox BF_leftCorner = Hurtbox(true, 52, 85,
SHAPE_CIRCLE, 8,
1, 0,0, 0, 0);
const Hurtbox BF_rightCorner = Hurtbox(
true, 268, 85, SHAPE_CIRCLE,8,
1, 1,1, 0, 0);
const Hurtbox SV_leftCorner = Hurtbox(true, 10, 63,
SHAPE_CIRCLE, 11,
1, 0,0, 0, 0);
const Hurtbox SV_rightCorner = Hurtbox(
true, 287, 61, SHAPE_CIRCLE,8,
1, 1,1, 0, 0);
double Stage::ceil(double x, double y) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
return CEIL_MAX;
// if(x <= 38 || x >= 288 || y >= 104) return CEIL_MAX;
// else if(x <= 159) return -0.6198 * x + 93.55;
// else return .6198 * x -103.55;
case STAGE_TOWER:
return CEIL_MAX;
case STAGE_BATTLEFIELD:
return CEIL_MAX;
// if(x <= 52 || x >= 268 || y >= 86) return CEIL_MAX;
// else if(x <= 161) return -.5505* x + 83.624;
// else return .5607 * x -95.28;
case STAGE_SMASHVILLE:
if(x <= 232 && x >= 100 && y <= 50) return 5;
else return CEIL_MAX;
case STAGE_EER:
return CEIL_MAX;
case STAGE_GREGORYGYM:
return CEIL_MAX;
}
return CEIL_MAX;
}
double Stage::floor(double x, double y) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
if(x >= 38 && x <= 288 && y >= 104) return 104;
else return FLOOR_MAX;
case STAGE_TOWER:
return 1;
case STAGE_BATTLEFIELD:
if(y >= 151 && x >= 135 && x <= 185) return 151;
if(y >= 119 && x >= 76 && x <= 128) return 119;
if(y >= 119 && x >= 193 && x <= 244) return 119;
if(x >= 52 && x <= 268 && y >= 86) return 86;
else return FLOOR_MAX;
case STAGE_SMASHVILLE:
if(x >= sv_platform_x && x <= sv_platform_x + SMASHVILLE_PLATFORM_LENGTH
&& y >= sv_platform_y + SMASHVILLE_PLATFORM_HEIGHT) return sv_platform_y + SMASHVILLE_PLATFORM_HEIGHT;
if(x >= 35 && x <= 295 && y >= 65) return 65;
else return FLOOR_MAX;
case STAGE_EER:
if(y >= 167 && x >= 94 && x <= 241) return 167;
if(y >= 139 && x >= 93 && x <= 242) return 139;
if(y >= 108 && x >= 92 && x <= 243) return 108;
if(y >= 77 && x >= 91 && x <= 244) return 77;
if(y >= 43 && x >= 88 && x <= 247) return 43;
return FLOOR_MAX;
case STAGE_GREGORYGYM:
if(y >= 164 && x >= 138 && x <= 190) return 164;
if(y >= 53 && x >= 78 && x <= 248) return 53;
else return 1;
}
return FLOOR_MAX;
}
double Stage::rightBound(double x, double y) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
if(x < 38 && y < 104 && y > 70) return 38;
if(y < 70 && x <= 159) return (y - 93.55) / -0.6198;
return RIGHT_MAX;
case STAGE_TOWER:
return RIGHT_MAX;
case STAGE_BATTLEFIELD:
if(x < 52 && y < 86 && y > 55) return 52;
if(y <= 55 && x <= 161) return (y - 83.624) / -0.5505;
return RIGHT_MAX;
case STAGE_SMASHVILLE:
if(y < 65 && y >= 20 && x <= 80 && x >= 13) return (y - 75.38) / -.6923;
return RIGHT_MAX;
case STAGE_EER:
return RIGHT_MAX;
case STAGE_GREGORYGYM:
return RIGHT_MAX;
}
return RIGHT_MAX;
}
double Stage::leftBound(double x, double y) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
if(x > 280 && y < 104 && y > 70) return 280;
if(y <= 70 && x >= 159) return (y + 103.55) / 0.6198;
return LEFT_MAX;
case STAGE_TOWER:
return LEFT_MAX;
case STAGE_BATTLEFIELD:
if(x > 268 && y < 86 && y > 55) return 268;
if(y <= 55 && x >= 161) return (y + 95.28) / 0.5607;
return LEFT_MAX;
case STAGE_SMASHVILLE:
if(y < 65 && y >= 5 && x >= 232) return (y+215.95)/0.9524;
return LEFT_MAX;
case STAGE_EER:
return LEFT_MAX;
case STAGE_GREGORYGYM:
return LEFT_MAX;
}
return LEFT_MAX;
}
double Stage::getStartX(uint8_t player) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
if(player == 1) return 60;
else return 232;
case STAGE_TOWER:
if(player == 1) return 60;
else return 232;
case STAGE_BATTLEFIELD:
if(player == 1) return 60;
else return 232;
case STAGE_SMASHVILLE:
if(player == 1) return 60;
else return 232;
case STAGE_EER:
if(player == 1) return 100;
else return 192;
case STAGE_GREGORYGYM:
if(player == 1) return 60;
else return 200;
}
return 0;
}
double Stage::getStartY(uint8_t player) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
return 104;
case STAGE_TOWER:
return 1;
case STAGE_BATTLEFIELD:
return 86;
case STAGE_SMASHVILLE:
return 65;
case STAGE_EER:
if(player == 1) return 139;
else return 77;
case STAGE_GREGORYGYM:
if(player == 1) return 1;
else return 53;
}
return 0;
}
bool Stage::onPlatform(double x, double y) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
return false;
case STAGE_TOWER:
return false;
case STAGE_BATTLEFIELD:
if(y == 119 && x >= 76 && x <= 128) return true;
if(y == 151 && x >= 135 && x <= 185) return true;
if(y == 119 && x >= 193 && x <= 244) return true;
case STAGE_SMASHVILLE:
if(x >= sv_platform_x && x <= sv_platform_x + SMASHVILLE_PLATFORM_LENGTH
&& y == sv_platform_y + SMASHVILLE_PLATFORM_HEIGHT) return true;
return false;
case STAGE_EER:
if(y == 167 && x >= 94 && x <= 241) return true;
if(y == 139 && x >= 93 && x <= 242) return true;
if(y == 108 && x >= 92 && x <= 243) return true;
if(y == 77 && x >= 91 && x <= 244) return true;
if(y == 43 && x >= 88 && x <= 247) return true;
case STAGE_GREGORYGYM:
if(y == 164 && x >= 138 && x <= 190) return true;
if(y == 53 && x >= 78 && x <= 248) return true;
else return false;
}
return false;
}
double Stage::xVelocity(double x, double y) {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
return 0;
case STAGE_TOWER:
return 0;
case STAGE_BATTLEFIELD:
return 0;
case STAGE_SMASHVILLE:
if(onPlatform(x, y)) return sv_platform_xvel;
return 0;
case STAGE_EER:
return 0;
case STAGE_GREGORYGYM:
return 0;
}
return 0;
}
void Stage::update() {
switch(stageIndex) {
case STAGE_FINALDESTINATION:
break;
case STAGE_TOWER:
break;
case STAGE_BATTLEFIELD:
break;
case STAGE_SMASHVILLE:
SpriteSendable s;
s.charIndex = 3;
s.animationIndex = 20;
s.framePeriod = 1;
s.frame = 0;
s.persistent = false;
s.continuous = false;
s.x = (int16_t) sv_platform_x;
s.y = (int16_t) sv_platform_y;
s.layer = LAYER_NAMETAG;
s.mirrored = false;
UART_sendAnimation(s);
if(sv_platform_goingRight) {
if(sv_platform_x > SMASHVILLE_PLATFORM_DECELPOINTRIGHT) sv_platform_xvel -= SMASHVILLE_PLATFORM_ACCELERATON;
else sv_platform_xvel += SMASHVILLE_PLATFORM_ACCELERATON;
if(sv_platform_xvel > SMASHVILLE_PLATFORM_MAXSPEED) sv_platform_xvel = SMASHVILLE_PLATFORM_MAXSPEED;
else if(sv_platform_xvel < 0) {
sv_platform_goingRight = false;
sv_platform_xvel = 0;
}
sv_platform_x += sv_platform_xvel;
} else {
if(sv_platform_x < SMASHVILLE_PLATFORM_DECELPOINTLEFT) sv_platform_xvel += SMASHVILLE_PLATFORM_ACCELERATON;
else sv_platform_xvel -= SMASHVILLE_PLATFORM_ACCELERATON;
if(sv_platform_xvel < -SMASHVILLE_PLATFORM_MAXSPEED) sv_platform_xvel = -SMASHVILLE_PLATFORM_MAXSPEED;
else if(sv_platform_xvel > 0) {
sv_platform_goingRight = true;
sv_platform_xvel = 0;
}
sv_platform_x += sv_platform_xvel;
}
break;
case STAGE_EER:
break;
case STAGE_GREGORYGYM:
break;
}
}
void Stage::initialize(uint8_t index, HitboxManager *hitboxManager) {
stageIndex = index;
if(stageIndex == STAGE_FINALDESTINATION) {
hitboxManager->addHurtboxFullConfig(0, 0, false,
FD_leftCorner, 0, true);
hitboxManager->addHurtboxFullConfig(0, 0, false,
FD_rightCorner, 0, true);
}
else if(stageIndex == STAGE_TOWER) {}
else if(stageIndex == STAGE_BATTLEFIELD) {
hitboxManager->addHurtboxFullConfig(0, 0, false,
BF_leftCorner, 0, true);
hitboxManager->addHurtboxFullConfig(0, 0, false,
BF_rightCorner, 0, true);
}
else if(stageIndex == STAGE_SMASHVILLE) {
hitboxManager->addHurtboxFullConfig(0, 0, false,
SV_leftCorner, 0, true);
hitboxManager->addHurtboxFullConfig(0, 0, false,
SV_rightCorner, 0, true);
sv_platform_goingRight = true;
sv_platform_x = 20;
sv_platform_y = 115;
sv_platform_xvel = 0;
}
else if(stageIndex == STAGE_EER) {
}
else if(stageIndex == STAGE_GREGORYGYM) {
}
}