-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathso_long.h
107 lines (95 loc) · 2.73 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zhlim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/09 17:05:42 by zhlim #+# #+# */
/* Updated: 2023/07/25 12:45:15 by zhlim ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SO_LONG_H
# define SO_LONG_H
# include "libft/ft_printf/include/ft_printf.h"
# include "libft/get_next_line/get_next_line.h"
# include "libft/libft.h"
# include <fcntl.h>
# include <mlx.h>
# include <stdlib.h>
# include <unistd.h>
# define RED "\033[0;31m"
# define NONE "\033[0m"
# define TILESIZE_X 32
# define TILESIZE_Y 32
# define BACKGROUND_PATH "./textures/Background.xpm"
# define WALL_PATH "./textures/Wall.xpm"
# define EXIT_CLOSED_PATH "./textures/Exit(Closed).xpm"
# define EXIT_OPENED_PATH "./textures/Exit(Opened).xpm"
# define COLLECTIBLES_PATH "./textures/Treasure.xpm"
# define CHARACTER_PATH "./textures/Front1.xpm"
# define EMPTY '0'
# define WALL '1'
# define PLAYER 'P'
# define EXIT 'E'
# define COLLECTIBLE 'C'
# define ESC 53
# define UP 126
# define DOWN 125
# define LEFT 123
# define RIGHT 124
# define W 13
# define S 1
# define A 0
# define D 2
# define Q 12
typedef struct s_img
{
void *img;
int width;
int height;
} t_img;
typedef struct s_graphic
{
t_img background;
t_img wall;
t_img character;
t_img exit_closed;
t_img exit_opened;
t_img collectibles;
} t_graphic;
typedef struct s_coord
{
int x;
int y;
} t_coord;
typedef struct s_map
{
void *mlx;
void *mlx_win;
char **grid;
t_graphic graphic;
t_coord player;
t_coord exit;
int start_count;
int exit_count;
int collectible_count;
int rows;
int columns;
int exit_opened;
int exited;
int collected;
int walk_count;
} t_map;
void print_error_exit(char *msg);
void validate_map(char *av, t_map *map);
void save_as_grid(int fd, t_map *map);
void initialize_mlx(t_map *map);
void free_error_exit(t_map *map, char *msg);
void lines_check(t_map *map);
void path_check(t_map *map);
int key_hook(int keycode, t_map *map);
void free_map(t_map *map);
int render(t_map *map);
void destroy_images(t_map *map);
#endif