-
Notifications
You must be signed in to change notification settings - Fork 0
/
so_long.h
169 lines (140 loc) · 3.37 KB
/
so_long.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hgrissen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/04 10:17:07 by hgrissen #+# #+# */
/* Updated: 2021/11/06 15:42:56 by hgrissen ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SO_LONG_H
# define SO_LONG_H
# include <sys/types.h>
# include <sys/stat.h>
# include <unistd.h>
# include <fcntl.h>
# include <stdio.h>
# include <stdlib.h>
# include <mlx.h>
# include <math.h>
# include <sys/time.h>
# include <signal.h>
# include <string.h>
# include "./basic/libft.h"
# include "./gnl/get_next_line.h"
# define FLT_MAX 3.402823e+38
# define W 1080
# define H 720
# define A_KEY 0
# define D_KEY 2
# define S_KEY 1
# define W_KEY 13
# define ESC_KEY 53
# define L_ARR 123
# define R_ARR 124
# define U_ARR 126
# define D_ARR 125
# define SPACE 49
# define TAB 48
# define TILESIZE 64
typedef struct s_elements
{
int p;
int c;
int e;
} t_elements;
typedef struct s_pos
{
int x;
int y;
} t_pos;
typedef struct s_input
{
int pressed;
int up;
int down;
int left;
int right;
} t_input;
typedef struct s_img {
void *img;
unsigned int *addr;
int bpp;
int ll;
int end;
} t_img;
int g_width;
int g_height;
int g_x;
int g_y;
typedef struct s_textures
{
t_img p;
t_img e;
t_img c;
t_img w;
t_img s;
} t_textures;
typedef struct s_player
{
t_input input;
int step;
int coins;
int collected;
int col_bool;
int end;
char **map;
} t_player;
typedef struct s_mlx
{
void *mlx;
void *mlx_win;
void *img;
char *addr;
int bpp;
int ll;
int end;
t_player *plyr;
t_textures tex;
char **av;
} t_mlx;
int update(void *mlx);
int ft_quit(void);
int exit_error(int error);
void my_mlx_pixel_put(t_mlx *data, int x, int y, int color);
void rect(t_mlx *mlx, int x, int y, t_img tex);
void draw_map(t_mlx *mlx, char **map);
void move_player(t_mlx *mlx);
int get_coins(char **map);
/*
collisions
*/
int exit_collision(char **map, t_pos *pos, t_input input);
int wall_collision(char **map, t_pos *pos, t_input input);
int col_collision(char **map, t_pos *pos, t_input input);
/*
inputs
*/
void refresh_input(t_input *input);
void get_input(t_mlx *mlx);
int key_pressed(int key, t_mlx *mlx);
int key_released(int key, t_mlx *mlx);
char **get_map(char **av);
void check_map_closed(char **map);
void check_map_chars(char *str);
void check_elements_count(char *str);
char *get_file(char **av);
void init_player(t_mlx *mlx, char **map);
t_mlx *init_canvas(void);
void draw_others(t_mlx *mlx, char **map);
void game(t_mlx *mlx);
int check_input(t_input input);
void resolution(char **map);
void get_texture(t_mlx *mlx);
void check_tex_err(t_mlx *mlx, int code);
uint64_t get_time(void);
void play_damage_sfx(int i);
uint64_t starttime;
#endif