blob: a97ff2d7b4ae80d031c65dc136149d689ebfdc83 (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d_structs.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:20:05 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:20:06 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
# ifndef CUB3D_STRUCTS_H
# define CUB3D_STRUCTS_H
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <time.h>
#include <pthread.h>
typedef struct s_win
{
void *wlx;
void *winptr;
uint8_t inited;
uint16_t x_max_size;
uint16_t y_max_size;
uint32_t x_size;
uint32_t y_size;
} t_win;
# pragma pack(push, 1)
typedef struct s_bmp_file
{
uint16_t file_type;
uint32_t file_size;
uint16_t reserv_one;
uint16_t reserv_two;
uint32_t offset_data;
} t_bmp_file;
typedef struct s_bmp_info
{
uint32_t size;
int32_t width;
int32_t height;
uint16_t planes;
uint16_t bit_count;
uint32_t compression;
uint32_t size_image;
int32_t x_pixels_per_meter;
int32_t y_pixels_per_meter;
uint32_t colors_used;
uint32_t colors_important;
} t_bmp_info;
typedef struct s_sfx
{
char *cmd;
char *cmd_alt;
pthread_t tid;
pthread_mutex_t mutex;
void (*sfx_play)(struct s_sfx *);
} t_sfx;
typedef struct s_bmp_rgb
{
uint8_t r;
uint8_t g;
uint8_t b;
} t_bmp_rgb;
# pragma pack(pop)
typedef struct s_img
{
void *img;
char *ptr;
int bpp;
int sizeline;
int endian;
int img_w;
int img_h;
int tex_x;
int tex_y;
int tex_x_alt;
int tex_y_alt;
} t_img;
typedef struct s_rgb
{
int16_t r;
int16_t g;
int16_t b;
} t_rgb;
typedef struct s_sprite
{
int32_t spritescreenx;
int32_t current_sprite;
int32_t x;
int32_t y;
int32_t tex_x;
int32_t tex_y;
double s_pos_x;
double s_pos_y;
double spritex;
double spritey;
int8_t exists;
int32_t spriteheight;
int32_t spritewidth;
int32_t drawstartx;
int32_t drawstarty;
int32_t drawendx;
int32_t drawendy;
int32_t s_tex_y;
double transformx;
double transformy;
double sprite_dist;
double invdet;
} t_sprite;
typedef struct s_player
{
double pos_x;
double pos_y;
float pos_z;
float start_x;
float start_y;
float dir_x;
float dir_y;
float cam_x;
float plane_x;
float plane_y;
uint8_t fire;
int16_t life;
uint8_t has_weapon[3];
int8_t handles_weapon;
int16_t ammo[3];
} t_player;
typedef struct s_ray
{
uint16_t line_h;
float wall_dist;
float x_ray_pos;
float y_ray_pos;
float x_ray_dir;
float y_ray_dir;
float x_side_dist;
float y_side_dist;
float x_delta_dist;
float y_delta_dist;
int16_t wall_t;
int16_t wall_b;
uint8_t side;
size_t sqx;
size_t sqy;
uint8_t hit;
double wall_hit_x;
double step_tex_v;
float x_f_ray_dir;
float y_f_ray_dir;
float x_f_ray_dir_bis;
float y_f_ray_dir_bis;
uint16_t p;
float row_dist;
float x_floor;
float y_floor;
int32_t *tex_x_tab;
int32_t ***fc_tex_x_tab;
int32_t ***fc_tex_y_tab;
float *row_dist_tab;
int16_t *wall_t_tab;
int16_t *wall_b_tab;
uint8_t *w_side_tab;
uint16_t *line_h_tab;
float *wall_dist_tab;
} t_ray;
typedef struct s_map
{
char *filename;
char *no_tex_path;
char *so_tex_path;
char *ea_tex_path;
char *we_tex_path;
char *nl_tex_path;
char *fl_tex_path;
char *ce_tex_path;
char *nlevel_path;
char *traps_path;
char *music_path;
char *music_cmd;
char *mapl;
char **sprite_path;
char **map;
int8_t x_step;
int8_t y_step;
size_t map_w;
size_t map_h;
size_t mapl_len;
int16_t sprite_nbr[FT_TOTAL_SPRT];
uint8_t sprite_var;
int32_t sprite_order[FT_TOTAL_SPRT][4096];
int32_t st_o[FT_TOTAL_SPRT + 1];
size_t line_chk;
size_t map_start;
uint8_t isspawn;
uint8_t isnlvl;
uint8_t ismusic;
uint8_t isftex;
uint8_t isctex;
uint8_t istraps;
uint8_t isheals;
uint8_t darklvl;
uint16_t scale;
int8_t topsp;
uint32_t nlx;
uint32_t nly;
float x_floor_step;
float y_floor_step;
} t_map;
typedef struct s_bad_boy
{
int8_t life;
int8_t does;
int8_t sleep;
int8_t isdead;
void (*act[3])(struct s_bad_boy*, struct s_sprite*, t_map*);
} t_bad_boy;
typedef struct s_cub
{
uint8_t w_side;
uint8_t ishud;
uint8_t walltexgood;
uint8_t isoldmus;
uint8_t doicast;
uint16_t currlvl;
uint16_t i;
uint16_t y;
float **big_t;
uint16_t big_t_val;
char errmsg[64];
int32_t key_input[5];
char fps_count[9];
pthread_t mtid;
int8_t isdead;
uint8_t moves;
uint16_t map_back_h;
uint16_t map_back_w;
uint16_t amm_back_h;
uint16_t amm_back_w;
uint16_t life_cap_h;
uint16_t life_cap_w;
uint16_t life_num_h;
uint16_t life_num_w;
uint16_t ammo_cap_h;
uint16_t ammo_cap_w;
uint16_t ammo_num_h;
uint16_t ammo_num_w;
int (*key_ptr[6])(struct s_cub*);
int8_t (*get_ptr[14])(char**, struct s_cub*);
char ref[22][3];
struct s_win wlist;
struct s_player plist;
struct s_map mlist;
struct s_ray rlist;
struct s_img img;
struct s_img death_screen;
struct s_rgb f_rgb;
struct s_rgb c_rgb;
struct s_img tlist[27];
struct s_img tweap[6];
struct s_img tnum[12];
struct s_sprite **sprites;
struct s_sfx sfx[16];
struct s_bad_boy *bad_boy;
} t_cub;
# endif
|