-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathso_long.h
More file actions
127 lines (111 loc) · 3.12 KB
/
so_long.h
File metadata and controls
127 lines (111 loc) · 3.12 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* so_long.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aylaaouf <aylaaouf@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/14 03:21:32 by aylaaouf #+# #+# */
/* Updated: 2025/03/20 07:12:52 by aylaaouf ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SO_LONG_H
# define SO_LONG_H
# include <fcntl.h>
// # include <mlx.h>
# include "gnl/get_next_line.h"
# include "libft/libft.h"
# include "minilibx-linux/mlx.h"
# include "printf/ft_printf.h"
# define TILE_SIZE 64
typedef struct s_map
{
int width;
int height;
char **map;
} t_map;
typedef struct s_enemy
{
int x;
int y;
int direction;
} t_enemy;
typedef struct s_game
{
void *mlx;
void *win;
int player_x;
int player_y;
int moves_count;
char *moves_count_str;
t_map *map;
void *player;
void *empty_space;
void *killer;
void *wall;
void *coin;
void *gate;
void *animation;
t_enemy enemy;
int enemy_count;
} t_game;
typedef struct s_var
{
int player;
int exit;
int coins;
} t_var;
enum e_keys
{
ESC_KEY = 65307,
UP_KEY = 65362,
DOWN_KEY = 65364,
LEFT_KEY = 65361,
RIGHT_KEY = 65363
};
typedef struct s_pos
{
int x;
int y;
} t_pos;
// helpers for main file "norminette"
int check_path(char *filename);
void helper_valid_path(t_game *game);
void get_size_width_height(char **map, int *height, int *width);
void mlx_images(t_game *game);
void draw_map_helper(t_game *game, char place, int x, int y);
void draw_map(t_game *game);
void move_player(int new_x, int new_y, t_game *game);
void handle_movement(int key, t_pos *pos, t_game *game);
// parsing
void invalid_char(t_game *game);
void find_player_position(t_game *game);
void free_copy_of_map(char **map_copy);
void flood_fill(char **map, int x, int y);
int check_map_is_exist(char **map);
char **copy_map(char **map, int len);
int is_rectangular(t_map *map);
int is_wall(t_map *map);
int count_lines(char *filename);
t_map *read_map(char *filename);
int is_exist(t_map *map);
int no_collectible_more(t_game *game);
void valid_map(t_game *game, char *filename);
// utils
void ft_putchar_s(char c);
void ft_putnbr_s(int nbr);
// free func
void free_map(t_map *map);
void clean_game(t_game *game);
void free_images(t_game *game);
int close_window(t_game *game);
// game
int no_collectible_more(t_game *game);
// enemy
void find_enemy(t_game *game);
int find_enemy_before(t_game *game);
int enemy_patrol(t_game *game);
void helper(t_game *game);
int runer(t_game *game);
void helper_parsing(t_game *game, char *filename);
#endif