-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.h
245 lines (225 loc) · 5 KB
/
types.h
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
#ifndef __TYPES_H_
#define __TYPES_H_
/// @brief Game state values
typedef enum
{
MAINMENU = 0,
GAMEPLAY = 1,
ANIMTEST = 2,
PAUSED = 3,
MENU = 4
} gamestate_e;
/// @brief Hero state values
typedef enum
{
IDLE,
WALKING,
ATTACK,
JUMP,
CROUCHING,
HIT,
DYING
} herostate_e;
/// @brief Enemy state values
typedef enum
{
E_NORMAL,
E_HURT,
E_DYING
} enemystate_e;
/// @brief Hitbox definition
typedef struct
{
FIXED x;
FIXED y;
FIXED width;
FIXED height;
short type;
} hitbox_t;
/// @brief Dynamic hitbox definition
typedef struct
{
FIXED x;
FIXED y;
FIXED width;
FIXED height;
short type;
short attribute;
bool active;
} dynamic_hitbox_t;
/// @brief Camera
typedef struct
{
jo_camera cam;
FIXED x;
FIXED y;
FIXED z;
} camera_t;
/// @brief Gravity
typedef struct
{
FIXED max;
FIXED step;
} gravity_t;
/// @brief Collision
typedef struct
{
FIXED x;
FIXED y;
} collision_t;
/// @brief Hero animation keyframe
typedef struct
{
FIXED startframe;
FIXED length;
FIXED HEAD_translation[3];
short HEAD_rotation[3];
FIXED L_CALF_translation[3];
short L_CALF_rotation[3];
FIXED L_FARM_translation[3];
short L_FARM_rotation[3];
FIXED L_THIGH_translation[3];
short L_THIGH_rotation[3];
FIXED L_UARM_translation[3];
short L_UARM_rotation[3];
FIXED LOWER_translation[3];
short LOWER_rotation[3];
FIXED R_CALF_translation[3];
short R_CALF_rotation[3];
FIXED R_FARM_translation[3];
short R_FARM_rotation[3];
FIXED R_THIGH_translation[3];
short R_THIGH_rotation[3];
FIXED R_UARM_translation[3];
short R_UARM_rotation[3];
FIXED SHOULDER_translation[3];
short SHOULDER_rotation[3];
FIXED TORSO_translation[3];
short TORSO_rotation[3];
FIXED SWORD_translation[3];
short SWORD_rotation[3];
} anim_hero_keyframe_t;
typedef struct
{
FIXED startframe;
FIXED length;
FIXED HEAD_translation[3];
short HEAD_rotation[3];
FIXED L_CALF_translation[3];
short L_CALF_rotation[3];
FIXED L_FARM_translation[3];
short L_FARM_rotation[3];
FIXED L_THIGH_translation[3];
short L_THIGH_rotation[3];
FIXED L_UARM_translation[3];
short L_UARM_rotation[3];
FIXED LOWER_translation[3];
short LOWER_rotation[3];
FIXED R_CALF_translation[3];
short R_CALF_rotation[3];
FIXED R_FARM_translation[3];
short R_FARM_rotation[3];
FIXED R_THIGH_translation[3];
short R_THIGH_rotation[3];
FIXED R_UAM_translation[3];
short R_UAM_rotation[3];
FIXED SHOULDER_translation[3];
short SHOULDER_rotation[3];
FIXED TORSO_translation[3];
short TORSO_rotation[3];
} mesh_death_keyframe_t;
/// @brief Animation data
typedef struct
{
short id;
bool loop;
FIXED length;
short numberKeyframes;
const anim_hero_keyframe_t *frames;
bool play;
} animation_t;
/// @brief Playable hero definition
typedef struct
{
/// @brief X position
FIXED x;
/// @brief y position
FIXED y;
/// @brief z position
FIXED z;
/// @brief Horizontal speed
FIXED speedX;
/// @brief Vertical speed
FIXED speedY;
/// @brief Hero state
herostate_e state;
/// @brief Standing on ground
bool isGrounded;
/// @brief Facing left
bool isFacingLeft;
/// @brief Player hitbox
hitbox_t hitbox;
/// @brief Weapon hitbox
dynamic_hitbox_t sword;
/// @brief Weapon frame counter
short swordCounter;
/// @brief Hero health
short health;
/// @brief I-Frame counter
int invulnerability;
/// @brief Current animation pointer
const animation_t *currentAnimation;
/// @brief Advance animation frame counter
bool playAnimation;
/// @brief Animation frame counter
FIXED animationCounter;
/// @brief Current animation keyframe
int currentKeyframe;
} hero_t;
/// @brief Enemy
typedef struct
{
/// @brief Type id
short type;
/// @brief X position
FIXED x;
/// @brief Y position
FIXED y;
/// @brief Hitbox
hitbox_t hitbox;
/// @brief Enemy state
enemystate_e state;
/// @brief Health
short health;
/// @brief Is active
bool active;
/// @brief Facing left
bool isFacingLeft;
/// @brief Update routine
void (*update)(short idx);
/// @brief Draw routine
void (*draw)(short idx);
/// @brief spawning hitbox id
short hitboxId;
/// @brief Counter until enemy spawner hitbox is set to active again
short respawnCounter;
} enemy_t;
/// @brief Level definition
typedef struct
{
/// @brief Current level chunk
short currentChunk;
/// @brief Chunk draw routine
void (*const *display_geometry)(void);
/// @brief Number of chunks in the level
short chunks;
/// @brief Number of static hitboxes
short hitboxCount;
/// @brief Number of dynamic hitboxes
short dynamicHitboxCount;
FIXED boundaryLeft;
FIXED boundaryRight;
FIXED boundaryTop;
FIXED boundaryBottom;
} level_t;
#endif